Nodes/ComfyUI-UsefulStuffNodes/Any Input Selector
ComfyUI Node

Any Input Selector

A dozen maybe-sources in, one socket out, and a dice roll if you don't choose

By ArtemKo7v·Created 25 days ago·Updated a day ago· 0
Any Input Selector
  • any_1
  • selected
selected_index-1

You've got three prompts, or two upscale branches, or a pile of checkpoints, and you'd like one wire coming out the far side instead of rewiring the graph every time your mood changes. That's the entire job of Any Input Selector. It's a fan-in switch with a wildcard socket, and - this is the part nobody advertises - if you don't tell it which input to pass, it rolls a die and picks one for you.

What it is, and where it sits in a workflow

ComfyUI's switching story comes in two shapes, and it's worth knowing which one you're buying. A fallback switch walks its inputs and passes the first one that isn't empty (rgthree's Any Switch is the canonical one). An A/B switch has a selector you point at an input - a manual routing valve. Any Input Selector is the second shape, scaled to sixty-odd inputs instead of two.

The reason it's not redundant with the ones built into Impact Pack or WAS Node Suite is that it's type-agnostic. Its sockets use ComfyUI's * wildcard type, so the same node will route an IMAGE, a LATENT, a MODEL or a string, and you can leave your branch-swapping in one place regardless of what the branches produce. That's exactly the node people were hunting for in the early "is there a switch node in ComfyUI?" threads, where the answers were all per-type switches and the thread closed on "most seem to only accept lots of inputs and pass one output."

How it works

The required input is any_1, and each time you wire something up the frontend grows the next socket: any_2, any_3, and so on, always leaving one empty row at the bottom. Unwire the tail and the empty rows get pruned again, up to a ceiling of 64.

Then, on each run, it builds the list of connected inputs in socket order and reads selected_index:

  • 1 gives you any_1, 2 gives you the second connected input, and so on.
  • Anything out of range - including the default of -1 - means it picks a random connected input instead, using secrets.randbelow, i.e. the OS random source rather than a seed you can set.

That last bit is the trap and the feature at once. Index 2 means the second connected input, not the socket literally named any_2. Disconnect something in the middle and every index above it shifts down by one.

Inputs and outputs that matter

  • any_1 (required, wildcard) - your first source. Everything else appears as you connect.
  • selected_index (INT, default -1) - the one you actually set. -1 = random each run; a number = pin it. Keep it out of range and it quietly randomizes rather than erroring.
  • selected (wildcard output) - whatever came in, straight back out. Wire it into the sampler, the VAE decode, the CLIP encode, whichever consumer you were rewiring by hand.

One cosmetic gotcha the frontend introduces: it relabels every socket - and the output - with the type of your first input. So a node mixing an IMAGE on one row and a LATENT on another advertises itself as IMAGE and some downstream nodes will refuse the link. Selectors like this want homogeneous inputs. That's also the standing critique of type-erasing routing nodes in general: they hide the graph's types, which is fine right up until something breaks. Use it where you'd otherwise rewire; don't make it your wiring style.

Installing it

ComfyUI Manager, search the pack title ComfyUI Useful Stuff Nodes, or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/ArtemKo7v/ComfyUI-UsefulStuffNodes
# restart ComfyUI, then reload the browser page

There is nothing else to do. No model downloads, no pip install - the pack's requirements.txt is empty, pyproject.toml declares dependencies = [], and the code imports only secrets and time from the standard library. If you've been burned by a node pack dragging in a heavyweight detector library, this is the other kind. The nodes live under the ArtemKo7v category in the right-click menu, not under utils or logic, which is why people miss them.

Common issues

The sockets don't grow. The dynamic inputs are a browser-side JavaScript extension (web/js/dynamic_selectors.js), not a Python thing. Reload the page - a hard refresh if you're unsure. If you're running ComfyUI's Nodes 2.0 frontend and the behavior is flaky, that rewrite has broken exactly this class of LiteGraph-era extension for other packs; the legacy canvas is the fallback everyone uses.

Your batch produces a different branch every run. That's by design: the node declares itself always-changed, so it re-executes on every queue and takes everything behind it with it. Handy for "give me variety while I'm away", miserable if you're debugging - change one thing at a time, or pin selected_index while you work out what's wrong. And a random pick only re-runs what it feeds, so if the branch you land on looks stale, that's the cache doing its job rather than a bug.

CategoryArtemKo7v

Inputs (2)

NameTypeDefaultDescription
any_1*
selected_indexoptINT-1

Outputs (1)

NameTypeDescription
selected*