ComfyUI Node

Boolean Switch

A switch that doesn't care what you throw at it

By LaVie024·Created about a year ago·Updated 8 months ago· 8
Boolean Switch
  • on_true
  • on_false
  • output
switchtrue

Most switch nodes in the ComfyUI ecosystem are typed: a text switch swaps strings, an image switch swaps images, and heaven help you if the two things you want to swap aren't the same type. BooleanSwitch is the one that says "I don't care" - it takes anything, passes through one of two anything-wires based on a boolean, and hands you back the same anything. That one trick is why it quietly outranks the other switches in this pack.

What it's actually for

You wire on_true and on_false with two branches of a workflow, flip the switch input, and the node outputs whichever branch you picked - no rewiring, no bypassing half a graph. The classic setup is pairing it with a seed-driven random source or a DoesExist check so a whole branch activates conditionally. It's a genuinely nice ComfyUI pattern: instead of muting groups by hand, you let the graph decide for itself.

How it works

The trick is in how ComfyUI sees its input type. The node declares its optional inputs as * (AnyType), and the implementation overrides the equality operator so the type checker accepts every connection. On the ComfyUI side that means the sockets light up for anything - IMAGE, MODEL, STRING, LATENT, even a whole rgthree-style context bundle. The output is also *, so whatever went in comes back out unchanged. It's a pure router: no type conversion, no evaluation, no side effects. Give it a switch of True and you get on_true; False and you get on_false.

The inputs that matter

  • switch (BOOLEAN, default true) - the only required input, and the whole point. If you leave it alone the node is a permanent pass-through of on_true.
  • on_true / on_false (any) - the two candidates. Both are optional, so you can get away with only feeding the branch you'll actually use.
  • output - the survivor, wired into whatever the two branches would have fed.

That's the entire surface area. It's one of those nodes you look at and think "that's it?" - yes, and that's the appeal.

Installing it

It ships in the comfyui-lopi999-nodes pack, so you're really installing that:

cd ComfyUI/custom_nodes
git clone https://github.com/LaVie024/comfyui-lopi999-nodes

Then restart ComfyUI. ComfyUI Manager works too - search "comfyui-lopi999-nodes" in the custom nodes installer. The pack has no requirements.txt and downloads no models; a logic node like this one has zero heavy dependencies, though the pack as a whole does lean on a few (see the image nodes' gotchas).

Common issues

There's one behavior that trips people up: if a branch feeds it None (say, the source node is bypassed), the switch happily outputs None rather than falling through to the other branch. BooleanSwitch is a pass-through, not a fallback - if you want "use this unless it's missing," that's what DoesExist plus this node does, with a bit of wiring. Also remember the default is true, so an unconfigured node quietly routes to on_true. When your output suddenly looks like the wrong branch, that's the first place to look.

Categorylopi999/logic

Inputs (3)

NameTypeDefaultDescription
switchBOOLEANtrue
on_trueopt*
on_falseopt*

Outputs (1)

NameTypeDescription
output*