Nodes/deforum-comfy-nodes/Any Switch | Deforum
ComfyUI Node

Any Switch | Deforum

Pass the first input that isn't empty

By deforum·Created about a year ago·Updated 3 months ago· 29
Any Switch | Deforum
  • any_01
  • any_02
  • any_03
  • any_04
  • any_05
  • *

This is a first-non-null switch: it looks at its five inputs in order and passes along the first one that isn't empty. No selector widget, no boolean to flip - the graph decides which branch is live by which one actually produced a value. If you've used rgthree's Any Switch, you already know this node; Deforum ships its own flavor so animation workflows don't depend on another pack.

The inputs are any_01 through any_05, all * wildcard sockets, so it'll route a latent, a model, an image, a string - anything. One output, same type as whichever input won.

What "empty" means here

The clever bit is the emptiness check. An input counts as empty if it's None - the standard "unconnected optional input" signal in ComfyUI - but there's a second case the authors bothered to handle: a dict carrying model and clip keys where every value is None. That's the shape of an empty model bundle, which happens when a loader runs but loads nothing. So this switch is deliberately built to skip both "nothing connected" and "a loader that produced nothing," which makes it genuinely useful in Deforum workflows where model/CLIP pairs get swapped by conditions.

Why you'd reach for it

Two classic jobs. One: several optional upstream branches feeding one consumer - whichever branch is live wins, and you never touch a selector. Two: the null-output pattern from the plumbing layer, where an Execution Blocker or a conditional produces None to mute a branch, and the switch silently falls through to the next candidate. That combination - "try A, and if A was blocked/empty use B" - is the reason this node exists in a flow-heavy pack.

The trap to know

Fallback switches make graphs harder to debug, not easier - that's the exact tension the community called out in the "Anything Anywhere" backlash. When a switch silently passes input B because A was None, you can't see it from the canvas. If a workflow suddenly changes behavior, check whether an upstream branch you expected to be live actually produced anything. And note the ordering is fixed by the input names (any_01 first), so wire your preferred source into the lowest-numbered input.

Installing it

Ships in deforum-comfy-nodes, the official Deforum ComfyUI pack. ComfyUI Manager: search "deforum" (comfyui-deforum), install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/deforum-art/deforum-comfy-nodes

Restart ComfyUI after. No extra dependencies, no model downloads. Known load-error cause after upgrades: an orphaned deforum pip package; pip uninstall deforum and restart.

CategoryDeforum/Logic

Inputs (5)

NameTypeDefaultDescription
any_01opt*
any_02opt*
any_03opt*
any_04opt*
any_05opt*

Outputs (1)

NameTypeDescription
**