Condition Chain
If / else if / else, the legible way
- index
- matched
- count
If you've ever wished ComfyUI had an if / else if / else, this is the closest thing it ships. Condition Chain tests its conditions in order and answers with the position of the first one that holds. That's a number, not a boolean - which is exactly the trick, because a number plugs straight into an index switch and turns "which condition fired first" into "which branch runs."
Under WAS Suite/Logic/Boolean, it takes up to 26 boolean conditions (condition_a through condition_z) plus a fallback integer. Unconnected slots are skipped, so numbering always follows what's actually wired. The outputs:
index- the position of the first true condition, counting connected slots from 0. This is the number you wire into an index switch.matched- true when a real condition held, false when the fallback answered. Useful if you need to distinguish "condition three fired" from "nothing matched."count- how many conditions are connected.
The canonical pairing: chain → index switch
The pattern the node was built for is two nodes. Condition Chain's index goes into the index input of an Any Index Switch, and each of the switch's candidate slots holds one branch of your logic:
condition_atrue → index 0 → the switch passesinput_a(your firstifbranch)condition_btrue → index 1 →input_b(your firstelse if)- …and so on down the ladder.
- Nothing holds → the chain returns
fallback. Set it to -1 and it also setsmatchedfalse, and a negative index on the switch reads as its last slot - reserve that last slot for yourelsecase and the whole thing reads like a structured program.
Why do it this way instead of a pile of chained gates? Readability. Two nodes with named slots and a numbered ladder is far easier to trace than five nested gates, and because each condition is tested in order with short-circuiting semantics - the first true one wins, the rest never matter - you get deterministic priority for free. If several conditions are true at once, the earliest one in the chain decides, every time.
A genuinely useful concrete case
A prompt router is the classic build. Condition A: the image is portrait orientation → feed the portrait prompt. Condition B: landscape → the landscape prompt. Condition C: square → square crop prompt. Else → the generic prompt. Or a model selector: "if steps > 30 and CFG high → slow quality checkpoint; else if the video input has audio → audio-capable checkpoint; else → the fast one." Each condition is a Compare Any feeding a condition socket; the chain picks the first that fires; the index switch hands you the right pipeline. And only the winning branch evaluates, so the losers' loaders don't even run.
The one trap
The fallback defaults to 0, which means "nothing matched" quietly behaves exactly like "condition_a matched" unless you set it deliberately. That silent conflation is the classic source of "why is my else branch doing the if branch's job?" - if your graph has a real else case, set fallback to -1 and read matched, or wire the fallback to a dedicated slot you keep empty for "none." Otherwise a chain with no matching condition routes to slot 0 and looks like a successful match.
Installing
Part of WAS Node Suite v3 (WASasquatch/was-node-suite-comfyui), WASasquatch's MIT pack - going since 2023, one of the ecosystem's long-standing essentials. Logic nodes carry no dependencies at all: no pip packages, no weights, nothing to configure. Requires ComfyUI 0.14.0+ since the v3 suite targets ComfyUI's newer node backend.
Via ComfyUI Manager, search WAS Node Suite v3, or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui
Restart ComfyUI and it appears under WAS Suite/Logic/Boolean. Not in the menu after a fresh install? Your ComfyUI is older than 0.14.0 - update it and the pack's nodes register.
Inputs (27)
| Name | Type | Default | Description |
|---|---|---|---|
| fallback | INT | 0-1–25 | Answer when no condition holds; this is the `else`. -1 answers -1 and sets matched to false, which an index switch reads as its last slot. |
| condition_aopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_bopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_copt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_dopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_eopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_fopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_gopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_hopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_iopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_jopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_kopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_lopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_mopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_nopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_oopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_popt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_qopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_ropt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_sopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_topt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_uopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_vopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_wopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_xopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_yopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
| condition_zopt | BOOLEAN | false | One condition, `true` or `false`, tested in slot order. The first `true` decides the answer. An unconnected slot is skipped, so the numbering follows what is wired. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| index | INT | Position of the first true condition, counting connected slots from 0, or the fallback when none held. |
| matched | BOOLEAN | true when a condition held, false when the fallback answered. |
| count | INT | Connected conditions. The index runs 0..count-1. |