Nodes/ComfyUI-FBnodes/Switch Any Bool
ComfyUI Node

Switch Any Bool

A true/false router that only evaluates the branch you pick

By FranckyB·Created 6 months ago·Updated 3 days ago· 13
Switch Any Bool
  • on_true
  • on_false
  • output
  • bool
conditiontrue

Switch Any Bool is the "if this, run that" node for ComfyUI: a boolean condition picks between an on_true and an on_false input, and only the selected branch actually runs. It's the A/B switch from the plumbing layer, made lazy so that the branch you didn't pick costs you nothing - not even its upstream nodes.

It's part of ComfyUI-FBnodes, François Beaudry's utility pack, and it sits in the same family as the pack's Switch Any (the up-to-10-way version). Where you'd use it: "if this image is a portrait, use the portrait LoRA, else the landscape one," or "run the refine pass only when the checkbox is on."

How it works - the lazy part is the point

The mechanism is the ComfyUI lazy-input pattern. on_true and on_false are both declared with the * wildcard type (so they accept anything - MODEL, IMAGE, LATENT, you name it) and both marked lazy. Lazy means the node tells the execution engine which inputs it actually needs before the engine computes them: it looks at condition, and asks only for the matching branch. The inactive branch and everything upstream of it are never executed at all.

That's a real difference from a plain switch. A dumb switch waits for both inputs to be ready - meaning both model loaders on both sides of it get executed every run - and then throws one away. This node reads the condition first and requests only on_true or only on_false. In a workflow with two heavy branches (say, a full Wan gen on one side and a cached latent on the other), that's the difference between always paying for both and paying for one.

The condition input is a plain BOOLEAN, and the node also emits a bool output alongside the routed output, which is handy when the same decision needs to drive two switches in sync - wire the bool from one into the next.

The inputs

  • condition (BOOLEAN, default true) - the toggle.
  • on_true (*, optional) - what comes out when true.
  • on_false (*, optional) - what comes out when false.

Outputs: output (*) and bool (BOOLEAN).

Installing it

ComfyUI Manager - search "ComfyUI-FBnodes" - or:

cd ComfyUI/custom_nodes
git clone https://github.com/FranckyB/ComfyUI-FBnodes.git
pip install -r ComfyUI-FBnodes/requirements.txt

Restart ComfyUI. Pure routing logic - no models, no downloads.

Gotchas

The type system is loose here by design, so the node can't catch a type mismatch for you - if you route an IMAGE into a socket that wants a LATENT downstream, the error shows up downstream, not here. And remember the lazy behavior only skips work it can see: if you feed condition from a node that must run anyway (like a randomizer), that node still runs. Finally, if a branch errors, the node can't know whether you wanted the other one - lazy evaluation means the error is real, not a shortcut to the fallback. That's correct behavior, just worth knowing.

CategoryFBnodes

Inputs (3)

NameTypeDefaultDescription
conditionBOOLEANtrue
on_trueopt*
on_falseopt*

Outputs (2)

NameTypeDescription
output*
boolBOOLEAN