Switch
A switch that doesn't run the branches you didn't pick
Plain primitive "switch" nodes in ComfyUI have a dirty secret: they pick a value, but every branch feeding them still executes. Hook three prompts, three samplers or three whole model pipelines into one and you're paying for all of them every single run. ComfyUI-0246's Switch is different - it genuinely doesn't evaluate the inputs you don't select. That's the whole point of it, and it's why people who need conditional graphs put up with this node's rough edges.
Switch is part of Trung0246's ComfyUI-0246 pack, a self-described grab bag of "random nodes ... I made to solve my struggle with ComfyUI. Have varying quality." The author shipped it in early 2024 with the note that it's "still technically in beta but whatever." That's accurate: it works, but it's not a sit-and-forget node.
How it works
Switch is what's called a dynamic node - it starts with no fixed pins and grows them as you connect wires. Each output pin gets a dropdown widget next to it; you pick which of the node's inputs should feed that output. Set a widget to _ and that output simply isn't selected.
The clever part is in the execution graph. Before a run, Switch prunes the prompt so that everything upstream of a non-selected input is dropped from the graph. ComfyUI literally never runs those nodes. That's the difference between this and a Primitive-based switcher: no wasted sampler calls, no VRAM spent on a model you didn't choose, and - the sneaky win - a broken branch can't crash the run if you're not using it. You can leave a half-finished experiment wired in on an unselected pin and it just sits there.
Because the node's inputs and outputs are created on the fly, don't go looking for a fixed list of named ports. You'll see switch:-prefixed input pins and matching outputs; each output's combo widget is what selects the source. Connect a wire, pick a value, done.
Where it earns its keep
- A/B testing - two prompts or two CFG values, one toggle, only the active one runs.
- Model/sampler roulette - route a choice between checkpoints or samplers without paying for both.
- Workflow triage - leave an experimental branch attached but switched off; it costs nothing and can't break anything.
If you only ever switch between two strings, don't bother - a normal primitive switcher is simpler and more stable. Switch earns its keep the moment the branches are expensive to execute. And if you're building in the pack's Loop/Hold/Junction family, this is the natural routing node for picking data per iteration.
Installing it
Same pack, same install. In ComfyUI Manager, search "ComfyUI-0246" and install. Or from the terminal:
cd ComfyUI/custom_nodes
git clone https://github.com/Trung0246/ComfyUI-0246
Restart ComfyUI; the nodes show up under the 0246 category. No model files to download - this pack is pure code. Dependencies are light (wrapt, natsort, wat-inspector), and the pack attempts to auto-install wrapt/natsort if they're missing at load time.
Troubleshooting
Here's the honest part: Switch achieves its laziness by rewriting the execution prompt under the hood, and that's the most fragile kind of custom-node behavior. ComfyUI updates have historically broken exactly this sort of internal poking. The author's own source carries a TODO about re-checking prompt cleanup, and the pack's most interesting nodes stopped getting heavy maintenance around 2024. If Switch starts misbehaving after a ComfyUI update, update the pack first - and if that doesn't fix it, check the pack's GitHub issues, because "update broke 0246" is a known genre there. For a beginner: it's worth it for conditional pipelines, just don't build your entire workflow on it.
Inputs (0)
No inputs
Outputs (0)
No outputs