ComfyUI Node

CRZ Switch

Pick between two inputs with a toggle, and the loser's branch never even runs

By CoreyCorza·Created 12 months ago·Updated 12 months ago· 42
CRZ Switch
  • false_input
  • true_input
  • output
valuefalse

CRZ Switch is the data router of the ComfyUI-CRZnodes pack: two inputs, one output, and a boolean that decides which input comes out the other side. It's the node you reach for when a workflow has two paths and you want one control to pick between them - and unlike the sibling CRZ Execute Switch, this one is about picking data, not about which pipeline executes. It's also the node people actually name when they recommend this pack, with one r/comfyui user calling it - and the toggle it pairs with - "goated."

The pattern that keeps coming up in the community is exactly this: a CRZ Boolean Toggle wired into the switch's boolean input, with the two things you want to choose between on the true and false inputs. One click, and the output flips from one data source to the other.

How it works

The Python is straightforward: true_input and false_input accept anything (typed *), value is the boolean, and the node returns the matching input. But there's a genuinely good detail hiding in there - lazy evaluation. The node implements check_lazy_status, which tells ComfyUI to only compute the input it's actually going to use. Wire an expensive image-processing chain into the true input and a cheap one into the false input, and when the switch picks false, the expensive chain never executes.

That's a real, useful difference from most stock switches. The frontend makes it visible too: it draws the active input socket in green and an S-curve from the active input to the output, so you can see at a glance which path is live.

Inputs and outputs

  • true_input (input, *) - the data that comes out when the boolean is true. First input socket, per the README.
  • false_input (input, *) - the data that comes out when the boolean is false. Second input socket.
  • value (input, BOOLEAN, default false) - the switch. Wire it from a CRZ Boolean Toggle, or set it on the node.
  • output (output, *) - whichever input the boolean selected.

Two data inputs, one boolean, one output.

Installing it

Standard pack install: ComfyUI Manager → search ComfyUI-CRZnodes → install → restart. No requirements, no models.

cd ComfyUI/custom_nodes
git clone https://github.com/CoreyCorza/ComfyUI-CRZnodes.git

Data switch vs execute switch - pick the right one

This is the decision that trips people up. CRZ Switch selects data and skips computing the unused branch thanks to lazy evaluation - use it to choose between two values, two prompts, two models. CRZ Execute Switch routes a single input to a true or false output and blocks the unused output's downstream entirely - use it to choose between two whole pipelines. If you only need to pick a value, this node is the lighter, better-fitting tool; if you need to decide which chain of nodes runs, that's Execute Switch's job.

Gotchas

The default value is false, so a fresh switch outputs false_input until you flip it - the classic "why is my true branch dead" moment. And because the node's own canvas logic reads the boolean live, a switch whose boolean comes from a Compare node gets its active state drawn correctly even before the graph runs - a nice touch, but it also means the socket coloring can lie to you if the boolean is mid-update. When in doubt, trust the output, not the colors. Also remember the lazy evaluation cuts both ways: if you expect both branches to compute (say, both write files), this node will skip the inactive one, which is exactly the behavior some users don't expect.

CategoryCRZ

Inputs (3)

NameTypeDefaultDescription
false_input*
true_input*
valueBOOLEANfalse

Outputs (1)

NameTypeDescription
output*