Switch V2
A switch that only needs the branch you picked
- on_false
- on_true
- output
Every workflow eventually wants an A/B switch: flip a boolean and the graph routes one way or the other. Two models, two prompts, two upscaler chains - same shape. The problem with a lot of switch nodes is that they demand both inputs be connected before they'll run, which means you build the dead branch even when you never use it. ComfySwitchNodeV2 ("Switch V2") is the lazier version: it only requires the branch you actually selected.
It's a thin node from the ComfyUI-FeiHou-Toolbox pack, written against ComfyUI's newer comfy_api.latest node API. Its whole personality is the lazy evaluation.
How it works
The node declares a switch boolean and two any-type inputs, on_true and on_false. Under the hood it uses ComfyUI's lazy-input mechanism - the engine asks the node which inputs it actually needs this run, and the node answers with only the selected branch. So the unselected side isn't just ignored, it's never executed. The KB's node-plumbing doc calls this exact pattern out: a switch is only possible because ComfyUI's wildcard type accepts any connection, and lazy inputs mean a dead branch costs nothing.
There's a validation step too: if the selected input isn't connected, you get a clear error instead of a silent None flowing downstream. (The author's messages are in Chinese - something like "please connect the relevant node to the true input" - which is worth knowing if you hit a red node with a message you can't read.)
Because the inputs use a match type rather than a fixed type, on_true and on_false can be images, latents, models, conditioning, strings - whatever you're routing. The single output carries whatever the selected branch passed.
Inputs and output
switch- a BOOLEAN selector. Wire it from aPrimitiveBoolean, a seed node's output, or any node that emits a boolean. You can also flip it directly as a widget.on_true/on_false- the two candidates. Only the selected one needs to be connected.output- the chosen value, wired into whatever consumes it.
That's the entire contract. It's the node you drop in when your "toggle" is already a boolean and you don't want to be forced to wire both halves.
Install
ComfyUI Manager (search ComfyUI-FeiHou-Toolbox), or:
cd ComfyUI/custom_nodes
git clone https://github.com/FX-FeiHou/ComfyUI-FeiHou-Toolbox
Restart ComfyUI and hard-refresh the browser. No extra Python dependencies; the pack needs a reasonably current ComfyUI since it uses the newer node API.
Gotchas
- Error on run, selected input empty - you picked a branch and didn't connect it. That's the node working as designed; connect the selected branch (or flip
switch). - Same-type trap - both branches should feed the same kind of thing. The match type is forgiving, but downstream consumers still expect a coherent type.
- Bypassed branches - a bypassed upstream on the selected side still counts as missing, because the node only checks connectivity, not whether the branch is active.
For routing between groups of nodes rather than two single wires, the same pack's FastGroupsBypassSwitch is the group-level version of this idea.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| switch | BOOLEAN | — | |
| on_falseopt | COMFY_MATCHTYPE_V3 | — | |
| on_trueopt | COMFY_MATCHTYPE_V3 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | COMFY_MATCHTYPE_V3 | — |