ComfyUI Node

Any Type Switch

A Switch That Doesn't Care What Type You Throw at It

By 5agado·Created 12 months ago·Updated 18 days ago· 1
Any Type Switch
  • on_true
  • on_false
  • OUTPUT
switchtrue

ComfyUI ships a pile of switches, and they're all type-locked: switch images, switch latents, switch conditionings, switch whatever else, each one its own node. The Any Type Switch from the Sagado pack is the one that says "I don't care what it is, just pick between these two." That sounds like a convenience, but it's actually a different category of node, and it has a party trick that makes it worth having even if you never hit a weird type.

The party trick: lazy evaluation

Flip the switch and it picks one of two inputs. Nothing unusual there. The interesting part is how: this node declares both inputs lazy, and its check_lazy_status tells ComfyUI to only evaluate the branch you actually selected. The unselected input never runs.

That's a real difference from the naive switch you'd write yourself. If your "false" branch is an expensive path - say, a whole second sampler chain or a heavy upscale - and the switch is on true, a lazy switch means that expensive branch isn't computed at all. In graphs that get big, this is what keeps a switch from silently costing you a KSampler's worth of time every run. It's also the polite way to build an A/B or "new vs. old" toggle in one workflow.

Inputs and output

  • on_true (*) - anything, returned when the switch is on.
  • on_false (*) - anything, returned when the switch is off.
  • switch (BOOLEAN, default true) - the toggle.
  • Output: OUTPUT (*) - whatever you selected, type preserved.

Because the type is *, you can even pass two different types through it and let a downstream node choke or not. That's usually a bug, but it's a flexible bug.

Install and gotchas

Same as the rest of the pack: ComfyUI Manager → search "Sagado Nodes for ComfyUI", or clone https://github.com/5agado/ComfyUI-Sagado-Nodes into custom_nodes, pip install -r requirements.txt, restart. No models, no extra deps.

The gotcha is the same one that applies to every "any type" node in ComfyUI: the UI can't always guess what the output is, so anything downstream that needs to know the type (like a node that only accepts IMAGE) may refuse to connect to a * socket. In practice it works fine because ComfyUI resolves the actual type at execution from what's wired in - but you'll occasionally fight the UI's type inference. If you only ever switch one type, a purpose-built switch is less fiddly; this node earns its keep when you need to switch whatever or when the lazy evaluation saves you real work.

CategorySagado-Nodes

Inputs (3)

NameTypeDefaultDescription
on_true*
on_false*
switchBOOLEANtrue

Outputs (1)

NameTypeDescription
OUTPUT*