🔀 Switch
The if/else node ComfyUI never shipped
- true_val
- false_val
- output
ComfyUI is a programming language with no keyboard, and every programming language needs an if/else. The 🔀 Switch is that if/else: three inputs, one output, zero magic. Feed it a true_val, a false_val, and a BOOLEAN condition, and it hands back one of the two values. condition on → you get true_val. Off → false_val. That's the whole node, and honestly that's most of what makes it useful - it's the cleanest routing primitive this pack has.
Where it shines is when you stop flipping the condition checkbox by hand and start wiring it. Convert the condition widget to an input and drive it from a Judge (the pack's comparison node), a logic gate, or a random boolean. Now you have the two model loaders in one graph and a switch that picks between them; a portrait/landscape check that reroutes your resize path; a "did the CFG fix it" gate. The classic combo is Judge → Switch: Judge decides, Switch routes. Judge gives you the boolean, Switch gives you the fork.
The sockets are all wildcard * type, which is the escape hatch that makes routing nodes possible in the first place - a switch doesn't care whether it's moving IMAGE, LATENT, CONDITIONING, or a string, so it declares every socket as "accept anything." Both branches can even be different types, though you'd usually keep them matched since whatever comes out has to satisfy the downstream node. The node recolors itself based on the condition state, so the graph shows you which branch is live without tracing wires.
One thing people get bitten by: both upstream branches still execute. The Switch selects, but ComfyUI has to evaluate everything feeding the node - both the true branch and the false branch run, and you just pick one result. If one of your two branches is an expensive pipeline (a full inpainting pass, say), you're paying for both every run. That's normal for this family of nodes and it's exactly what the Blocker node in this same pack is for: put a Blocker on the branch you don't want computed and drive it from the same condition. Routing value without wasted GPU.
Also worth knowing: like everything in this pack, Switch returns float("NaN") from IS_CHANGED, so it always re-executes and the selection flips take effect immediately. The same trick means it's always dirty - a switch sitting in front of a big loader makes that loader re-run every time, which is the standard cost of interactive routing and usually worth it. And note the outputs: just one, named output, type *. Wire it onward and let the downstream node enforce the type.
Install comes from the pack - ComfyUI Manager, search "ComfyUI-Logic-nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/playboy-dongan/ComfyUI-Logic-nodes
Restart ComfyUI and it's under the ⚡ Logic menu. No models, no dependencies for this node. If the README's shorter clone URL (ComfyUI-Logic) 404s, use the -nodes one above.
If you're coming from rgthree, think of this as the A/B switch shape (selector-based) rather than rgthree's first-non-null fallback - different job, same family. Once you've got Judge, Switch, and Blocker wired together, you've stopped babysitting your graph and started programming it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| true_val | * | — | |
| false_val | * | — | |
| condition | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | * | — |