Switch Any Valid
Let Switch Any Valid pick the image for you
- input_1
- input_2
- input_3
- input_4
- output
Here's the difference between the two nodes in benstaniford/comfy-image-switch: Image Switch has a dial you turn, and Switch Any Valid has no dial at all. It just looks at its inputs and hands you the first one that's actually valid. The name is the spec.
That makes it the more useful of the pair, in a sneaky way. Because none of its inputs are required and none are typed, it isn't limited to images - it works on anything a workflow can carry, which is exactly what the * types in its schema mean.
How it works
Four optional inputs, input_1 through input_4, one output named output. The author's own tooltips just call them "first/second/third/fourth optional input," which tells you all you need: this is a pass-through node with no processing. In the usual any-valid sense, it walks the inputs in order and returns the first one that isn't empty, skipping whatever's left unconnected.
Where Image Switch is manual - you pick a slot, it does what you say - this one is automatic fallthrough. That's the whole trick, and it's a genuinely useful one. You get to build one downstream chain and let the graph decide which upstream source feeds it:
- Feed it a face-detected crop when that stage ran, and the raw image when it didn't.
- Pass in an img2img result when a source image is loaded, and fall back to a txt2img output otherwise.
- Since it's untyped, that "downstream chain" can be model inputs, conditioning, latents - not just pixels.
Honestly, it's the same fallback idea the pack's README brags about for Image Switch ("if the slot is empty, use the first available image"), generalized to any type and to any number of valid sources.
The trap nobody warns you about
Untyped * routing is exactly the pattern that set the ComfyUI community off in the "stop using Anything Anywhere" arguments - the KB records a whole thread devoted to hating it. The criticism has teeth: when every wire is just "anything," the graph can't type-check anything for you, and a wrong connection fails weirdly downstream instead of immediately.
None of that means don't use this node. It means use it like an adult: keep each instance carrying one type at a time, and remember that "valid" means "isn't None," not "is what I meant." An empty image tensor is still a tensor, so a slot can look valid to the node and useless to you.
Installing and using it
Same pack as Image Switch, same zero-friction install. No models, no requirements.txt, no Python dependencies beyond what ComfyUI already has. Via Manager, search "ComfyUI Image Switch Node" or comfy-image-switch; manually:
cd ComfyUI/custom_nodes
git clone https://github.com/benstaniford/comfy-image-switch
Restart, and it appears under utils/switch. One quirk worth knowing: the README only documents the Image Switch node - Switch Any Valid is the silent sibling, so the handful of details in this article are all the documentation you're going to get. If your output comes back empty, check that at least one upstream input is actually connected and actually produced something; with all inputs optional, an empty node just returns nothing, and it won't tell you why.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| input_1opt | * | First optional input | |
| input_2opt | * | Second optional input | |
| input_3opt | * | Third optional input | |
| input_4opt | * | Fourth optional input |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | * | — |