Boolean Switch
Pick between two branches with one flag
- on_true
- on_false
- *
ComfyUI's graph has no if statement - every node just runs. Boolean Switch is one of the small workarounds the community keeps reinventing for that gap: give it a true/false flag, connect a value for each case, and it hands back whichever one matches the current flag. Flip the boolean, the whole downstream branch changes, with nothing else in the graph rewired.
Where it earns its keep
The obvious use is A/B comparison - two different LoRA stacks, two different prompt styles, two different upscale paths - where you want to flip between them with one toggle instead of dragging wires around every time you want to test the other option. It's also a clean way to build a "feature flag" into a workflow you're going to reuse: wire a Boolean Switch ahead of an expensive branch (a hires-fix pass, a face-restore step) and toggle it off when you're iterating fast, on when you want the full pipeline.
Because the switch's output type is a wildcard, it works on anything - images, models, conditioning, strings, latents. You're not limited to routing simple values.
The inputs and output
state(BOOLEAN, required) - the flag. True routeson_truethrough; false routeson_false.on_trueandon_false(both optional, wildcard*) - the two candidate values.- A single wildcard output carrying whichever one the flag selected.
There's no dedicated behavior documented for leaving one side unconnected, so the practical rule is: wire both sides if you actually intend to flip between them. If you only ever want one branch and are using this as a glorified on/off gate rather than a true switch, a simpler bypass or mute on the unused branch's nodes is usually clearer than relying on an empty socket.
How to install it
ComfyUI Manager: search DemonAlone-nodes-ComfyUI, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/DemonAlone/DemonAlone-nodes-ComfyUI
then restart. Pure logic node, no dependencies, no models - it's live as soon as the pack loads.
Common issues & troubleshooting
The wrong branch keeps coming through. Double-check the polarity - it's easy to assume on_true is "the one I want by default" when the boolean itself is sitting at false. Trace the state input back to whatever sets it (a manual toggle, or something computed) and confirm it's actually the value you think it is.
One side is unconnected and the run errors. Since this node doesn't document a specific fallback for a missing branch, don't rely on leaving a side empty - connect both on_true and on_false explicitly, even if one of them is just a duplicate of an upstream value.
I need more than two branches. This node is strictly binary. For a three-or-more-way selector you want an index-based switch instead (several other packs ship those under names like "Switch" or "Selector" with an integer index rather than a boolean) - Boolean Switch only ever picks between two.
Downstream node complains about the type it received. Remember the output type is whatever you fed it, dynamically - if on_true was an IMAGE and on_false was accidentally left as a STRING, the switch will happily pass either one through, and the mismatch only shows up once you're on the wrong branch. Keep both sides the same underlying type.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| state | BOOLEAN | — | |
| on_trueopt | * | — | |
| on_falseopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |