Any Input Switch
Pick One of 64 Branches — and Actually Skip the Other 63
- input_default
- input_1
- input_2
- input_3
- input_4
- input_5
- input_6
- input_7
- input_8
- input_9
- input_10
- input_11
- input_12
- input_13
- input_14
- input_15
- input_16
- input_17
- input_18
- input_19
- input_20
- input_21
- input_22
- input_23
- input_24
- input_25
- input_26
- input_27
- input_28
- input_29
- input_30
- input_31
- input_32
- input_33
- input_34
- input_35
- input_36
- input_37
- input_38
- input_39
- input_40
- input_41
- input_42
- input_43
- input_44
- input_45
- input_46
- input_47
- input_48
- input_49
- input_50
- input_51
- input_52
- input_53
- input_54
- input_55
- input_56
- input_57
- input_58
- input_59
- input_60
- input_61
- input_62
- input_63
- input_64
- output
Switch nodes are the plumbing that turns a ComfyUI graph into a small program. Any Input Switch is the version that scales: up to 64 branches, each carrying any data type - IMAGE, LATENT, MODEL, CLIP, whatever - routed by a plain text match. The catch that makes it interesting isn't the count, though. It's that the branches you don't pick never run.
That lazy-loading detail is the whole point. ComfyUI normally executes everything upstream of a node, so a plain switch that takes five IMAGE inputs still forces all five upstream pipelines to compute. This node declares its inputs as lazy and tells the engine, via check_lazy_status, exactly which one socket it needs this run. Wire up three different upscalers or two checkpoint loaders and only the selected branch's cost hits your VRAM. That's the real reason to reach for this over a hand-rolled Python switcher.
How it works
The backend does the matching; a small JS extension does the cosmetics. case_N isn't even in INPUT_TYPES - the frontend adds and removes those widgets dynamically to match your item_count, and stashes all the values into a hidden __case_json string widget that rides along in your saved workflow. So when you bump item_count from 3 to 5, two new case boxes and two new input_N sockets appear; drop it back and they vanish (your wiring is only removed if the socket is unconnected).
Matching is dead simple: switch_condition is compared with each case value as an exact, case-sensitive string, and the first hit wins. No match at all, or a condition that's empty, and you get input_default. It's the explicit-selector shape of switch - the same family as an A/B switch, but with a text selector and N ways - as opposed to rgthree's Any Switch, which walks inputs and picks the first non-empty one automatically. Different tools. If you want the graph to choose for you, use the fallback; if you want a dropdown worth of named routes, this.
The inputs that matter
item_count(INT, default 3, 1–64) - how many branches. This is the one you'll touch constantly.switch_condition(STRING) - the selector. A widget by default, but it can be wired to any node that outputs text, which is how this becomes programmable: an LLM node classifies your prompt and its answer drives the route.case_1…case_N- the match values you compare against. These are the JS-managed widgets, not backend inputs.input_1…input_N(*) - your branches;input_default(*) - the always-present fallback.output(*) - the one socket everything funnels into.
The * wildcard is standard for switches, so the node carries a VALIDATE_INPUTS that skips type-checking. Don't read that as "Anything Anywhere"-style type erasure across your whole graph - the sockets still show what you connected, and only one branch ever crosses the node.
Installing it
Straightforward, and it's the rare custom node with zero extra dependencies - the README says no pip install, and the requirements file agrees (it only mentions torch, which ComfyUI already has):
cd ComfyUI/custom_nodes
git clone https://github.com/shenymce/ComfyuiAnySwitch.git
Then restart ComfyUI and look under utils for "Any Input Switch." Or skip all that and use ComfyUI Manager - search "ComfyuiAnySwitch" and hit install. There's a bundled example.json you can drag in to see it wired up.
Gotchas
The one that'll bite first: an empty switch_condition never matches anything, so it always falls through to input_default. If your switch suddenly routes to the wrong branch, check for a stray space or a capitalization difference - matching is exact, and case values get trimmed while the condition doesn't. And remember this pack is new and tiny (one author, one node, essentially no community track record yet), so treat it as the lightweight tool it is: great for a styled multi-loader or multi-upscaler workflow, not the thing you'd build your whole pipeline's sanity on.
Inputs (68)
| Name | Type | Default | Description |
|---|---|---|---|
| item_count | INT | 31–64 | — |
| switch_condition | STRING | — | |
| input_defaultopt | * | — | |
| __case_jsonopt | STRING | {} | — |
| input_1opt | * | — | |
| input_2opt | * | — | |
| input_3opt | * | — | |
| input_4opt | * | — | |
| input_5opt | * | — | |
| input_6opt | * | — | |
| input_7opt | * | — | |
| input_8opt | * | — | |
| input_9opt | * | — | |
| input_10opt | * | — | |
| input_11opt | * | — | |
| input_12opt | * | — | |
| input_13opt | * | — | |
| input_14opt | * | — | |
| input_15opt | * | — | |
| input_16opt | * | — | |
| input_17opt | * | — | |
| input_18opt | * | — | |
| input_19opt | * | — | |
| input_20opt | * | — | |
| input_21opt | * | — | |
| input_22opt | * | — | |
| input_23opt | * | — | |
| input_24opt | * | — | |
| input_25opt | * | — | |
| input_26opt | * | — | |
| input_27opt | * | — | |
| input_28opt | * | — | |
| input_29opt | * | — | |
| input_30opt | * | — | |
| input_31opt | * | — | |
| input_32opt | * | — | |
| input_33opt | * | — | |
| input_34opt | * | — | |
| input_35opt | * | — | |
| input_36opt | * | — | |
| input_37opt | * | — | |
| input_38opt | * | — | |
| input_39opt | * | — | |
| input_40opt | * | — | |
| input_41opt | * | — | |
| input_42opt | * | — | |
| input_43opt | * | — | |
| input_44opt | * | — | |
| input_45opt | * | — | |
| input_46opt | * | — | |
| input_47opt | * | — | |
| input_48opt | * | — | |
| input_49opt | * | — | |
| input_50opt | * | — | |
| input_51opt | * | — | |
| input_52opt | * | — | |
| input_53opt | * | — | |
| input_54opt | * | — | |
| input_55opt | * | — | |
| input_56opt | * | — | |
| input_57opt | * | — | |
| input_58opt | * | — | |
| input_59opt | * | — | |
| input_60opt | * | — | |
| input_61opt | * | — | |
| input_62opt | * | — | |
| input_63opt | * | — | |
| input_64opt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | * | — |