Nodes/ComfyPanel/SwitchAuto
ComfyUI Node

SwitchAuto

First input that shows up wins

By Ginolazy·Created 6 months ago·Updated 2 days ago· 23
SwitchAuto
  • input1
  • input2
  • output

SwitchAuto has no buttons, no dropdown, no settings at all. It's a pure fallback: feed it two optional inputs, and it returns the first one that's actually connected, preferring input1 and falling back to input2. If both are empty you get None. That's the entire node, and it earns its place by solving a genuinely annoying problem.

The problem is optional inputs. Say you have a node downstream that can accept an optional image - a reference image, a ControlNet source, a mask to blend against. When you don't connect anything, the whole downstream chain can break, or worse, quietly do the wrong thing. SwitchAuto gives you a "use the override if one exists, otherwise the default" decision in one node.

How it works

Both inputs are optional * sockets, so they can carry an image, a latent, a conditioning, a string - whatever you need. At execution the node checks input1 first; if it's not None, that's the output. Otherwise it checks input2. Then output carries whatever won.

The decision is made on presence, not value. If input1 is connected, it's used, full stop. There's no threshold, no "is this a good value" logic. That's actually the point - it's a connection fallback, so you can wire up a primary path and a safety-net path and never think about which one is live.

What you'd use it for

The clean example: a manual-prompt path and an auto-prompt path. Connect your manual CLIP Text Encode to input1 and an automated prompt generator to input2 - while the manual node is wired and active it always wins, and if you ever disconnect it, the auto path takes over without you touching anything else. Same trick works for a source image or an override mask. It's the "default value" idiom of programming, translated to a graph.

The traps

Since input1 always wins when connected, you can't use this to "switch between" two live sources - for that you want SwitchAnyMute or SwitchAnyCombo from the same pack. And the None output when both are empty can be a silent landmine: whatever you wire output into needs to handle None gracefully, or you'll get a type error that's confusing to trace. If you're building a workflow someone else will reuse, it's usually worth putting an explicit value node on input2 as the guaranteed fallback instead of leaving it empty.

Installing it

It's part of ComfyPanel:

cd ComfyUI/custom_nodes
git clone https://github.com/Ginolazy/ComfyPanel

Restart ComfyUI, or search ComfyPanel in ComfyUI Manager. Requirements are the standard torch/numpy/Pillow plus kornia, scipy, and opencv-python. No models to download, no Photoshop plugin required.

CategoryComfyPanel/Utils

Inputs (2)

NameTypeDefaultDescription
input1opt*
input2opt*

Outputs (1)

NameTypeDescription
output*