ComfyUI Node

Bool Switch

The bool switch that doesn't run the branch you didn't pick

By bandifiu·Created about a month ago·Updated about a month ago· 0
Bool Switch
  • any_true
  • any_false
  • any
selecttrue

Every ComfyUI workflow eventually needs the same thing: a valve that picks one of two inputs based on a boolean. Maybe you're A/B testing two models, or you want one saved workflow to run a cheap preview branch or a full hi-res pass depending on a toggle. This node is that valve, and it has one feature most switch nodes don't: the branch you don't select never executes at all.

What it is

"Bool Switch" (class NNAnyBoolSwitchTyped) is an A/B switch with three inputs and one output. You feed it any_true and any_false - the * wildcard type means either socket will accept an image, a latent, a model, a string, whatever you throw at it - and a select boolean decides which one comes out the any output. select on (its default) passes any_true; off passes any_false. That's the whole job, and it's the job described in the pack's README: "Selects between two inputs based on a boolean condition."

The reason you might reach for this over rgthree's classic Any Switch is the shape of the logic. rgthree's fallback walks its inputs and picks the first non-null one - the graph chooses for you. This one is a manual routing valve: you flip the switch, which is the right tool when you want a deliberate choice between two live branches rather than a silent fallback.

The lazy part is the point

Here's where it stops being a boring switch. The any_true and any_false inputs are declared lazy in the source. That means ComfyUI's execution engine only asks for whichever input the switch actually selects. Wire a full KSampler stack into any_false, set select to on, and that whole sampler branch is never executed on that run - no wasted VRAM, no wasted seconds.

That's genuinely rare. Most switch nodes in ComfyUI pass data through once it exists, but the upstream branch runs anyway. With lazy evaluation, the cheap branch genuinely stays cheap. The flip side: if you wire something into any_false and flip the switch, ComfyUI will now suddenly execute that whole branch - so a workflow that felt instant can get slow the first time you toggle, and that's expected behavior, not a bug.

What you actually set

Only three inputs, and two of them are usually wired, not typed:

  • any_true / any_false - the two candidates. Connect anything.
  • select - the boolean that chooses. Wire it to a toggle node, or convert the widget to an input and drive it from anything that outputs a boolean.

The single output any is the selected value, wired straight into whatever you were going to feed. Since the output is also *, it drops into any socket.

Installing it

This ships inside the bandifiu/ComfyUI-NN-custom-nodes pack. Easiest is ComfyUI Manager - search "NN-custom-nodes" and install. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/bandifiu/ComfyUI-NN-custom-nodes

Then restart ComfyUI. Dependencies are just torch, numpy, pillow and tomli (Python <3.11) - nothing heavy, no model downloads. One heads-up: the pack is written against ComfyUI's newer V3 backend authoring API (io.ComfyNode), so if you peek at the source you won't find the old NODE_CLASS_MAPPINGS dictionary. That's "new", not "broken". The whole pack is GPL-3.0, which only matters if you're doing something weird with the code.

Gotchas

The obvious one is remembering which branch is which: select on = any_true, and the default is on, so if you wire your heavy branch into any_true by habit it runs by default. Also, because of lazy evaluation, an unconnected input isn't just None - if select points at a socket with nothing wired, execution will flag it. Keep both inputs connected, even if one is a simple passthrough node.

CategoryNN/util

Inputs (3)

NameTypeDefaultDescription
any_true*
any_false*
selectBOOLEANtrue

Outputs (1)

NameTypeDescription
any*