Switch
Route one of two values by condition, without rewiring your whole graph
- true
- false
- output
Every serious ComfyUI workflow ends up with the same problem: "sometimes I want prompt A, sometimes prompt B," and the answer is a switch - but a switch that only handles one type is a trap when your workflow mixes strings, latents, and images. Utility Switch from ComfyUI Extended sidesteps all of that with a single * (any-type) pair of inputs. Wire anything into true and false, feed a boolean into condition, and the matching value comes out the other side.
It's the pack's most reusable node, because it doesn't care what you route. This is the pattern that quality-of-life packs live on - rgthree's whole reputation is built on graph-level conveniences like this, and Utility Switch is the same idea with zero dependencies attached.
How it works
Three inputs, all doing exactly what their names say:
true(ANY) - returned when the condition is true.false(ANY) - returned when it's false.condition(BOOLEAN, defaultfalse) - the decider.
The output is a single output socket typed *, so ComfyUI treats it as whatever type flows through it. The implementation is literally return (true if condition else false, {}). There's no type coercion, no hidden validation - the node just passes through whichever branch you selected.
Where it gets interesting is upstream of the condition. Feed it the pack's PrimitiveBoolean, an UtilityExpression that computes a comparison like a > b, or any node that emits a boolean, and the switch becomes automatic. The pack's own example workflow does exactly this: an Expression computing a value, feeding a Utility Switch.
Install
Standard for this dependency-free pack:
cd /path/to/your/ComfyUI/custom_nodes
git clone https://github.com/rookiepsi/comfyui-extended.git
Restart ComfyUI; it lives under comfyui-extended/utility. Or use ComfyUI Manager, search "ComfyUI Extended", install, restart. No models, no pip dependencies.
Common issues
- Both inputs are required. Unconnected
trueorfalsemeans the node has nothing to pass. If you only need one branch wired, connect the other to a stub rather than leaving it dangling. - It's a routing node, not a merge. It doesn't combine values, it selects one. The other branch is simply discarded for that run.
- Type is determined by the wire. Since the sockets are
*, ComfyUI figures out the real type from what you connect. Mixing types betweentrueandfalse(image on one, text on the other) will produce an error downstream - keep both branches the same kind of thing.
Where it shines: A/B testing prompts, toggling between two samplers or models, or any "do X or Y" decision that should be a checkbox, not a graph edit. It won't change your life, but it'll stop you rewiring the same two wires for the tenth time.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| true | * | — | |
| false | * | — | |
| condition | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | * | — |