ComfyUI Node

Any Switch

Outputs the first input that isn't empty, automatically

By wenchengxiang·Created 2 months ago·Updated 9 days ago· 3
Any Switch
  • any_1
  • any_2
  • any_3
  • any_4
  • any_5
  • any_6
  • any_7
  • any_8
  • any_9
  • any_10
  • any_11
  • any_12
  • any_13
  • any_14
  • any_15
  • *

Any Switch is the automatic fallback switch - fifteen inputs, any_1 through any_15, and it walks them in order, outputting the first one that isn't empty. No selector, no dial, no boolean to flip. The node decides for you: whichever upstream branch is actually live wins. This is the same pattern rgthree's Any Switch popularized - the KB's node-plumbing doc calls it the canonical fallback shape, "chooses the first input that is not null/empty" - and this is this pack's version of it.

Why you'd reach for it: fallback logic lets you keep several optional branches feeding one downstream consumer. Load an image from a generator or fall back to a saved file. Use a refined conditioning if a branch produced one, otherwise pass the base conditioning. Whatever is live flows through; you never touch a control. That's the "graph as a small program" idea from the plumbing layer - decisions made by data presence instead of by hand.

The mechanism has one thoughtful detail most such switches lack. The source checks emptiness with an is_none helper that has a special case: a dict containing model and clip keys is treated as empty if either is None. That's the pack watching out for partially-populated model/CLIP context objects - a branch that loaded half a context doesn't count as a valid branch and gets skipped. Small, but it's the difference between a fallback that works and one that silently forwards garbage.

The two things that actually trip people:

  • First in the list wins, silently. If two branches are live, the lowest-numbered one wins and nothing tells you. That's by design, but it means the ordering of your inputs is your logic - move branches and you move the priority. If you want an explicit choice instead of an automatic one, that's Any Index in this pack, or a boolean switch.
  • An unconnected input is skipped, not an error. All fifteen are optional and default to None, so wiring in just two leaves thirteen harmless empty slots. If the output is None, every connected branch was empty - check upstream, not the switch.

Install is pack standard: ComfyUI Manager → search ComfyUI-Practical-Tools → install → restart, or git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools into ComfyUI/custom_nodes. No dependencies, no models. If you need five or twenty-five slots, the Simple and Strong siblings in this pack are the same node in different sizes.

CategoryPractical-Tools/utils

Inputs (15)

NameTypeDefaultDescription
any_1opt*—
any_2opt*—
any_3opt*—
any_4opt*—
any_5opt*—
any_6opt*—
any_7opt*—
any_8opt*—
any_9opt*—
any_10opt*—
any_11opt*—
any_12opt*—
any_13opt*—
any_14opt*—
any_15opt*—

Outputs (1)

NameTypeDescription
**—