Any Index Switch
Pick one of many inputs with a number
- index
- input_a
- input_b
- input_c
- input_d
- input_e
- input_f
- input_g
- input_h
- input_i
- input_j
- input_k
- input_l
- input_m
- input_n
- input_o
- input_p
- input_q
- input_r
- input_s
- input_t
- input_u
- input_v
- input_w
- input_x
- input_y
- input_z
- output
- resolved_index
- count
The A/B switch handles two options. Real life hands you five. Any Index Switch is the answer to "which of these N values do I want?" - you drive a number and it passes the matching input, whatever type those inputs are. Wire a counter or a loop index into it and a single switch becomes a rotating stage that steps through its inputs one run at a time.
Under WAS Suite/Logic/Switch, it takes up to 26 candidate inputs (input_a through input_z) of any type, plus an index. The output is the chosen input, and the whole thing types itself the way the other WAS switches do: first connection fixes the type, unconnected slots aren't counted. So if you wire only input_a, input_b, and input_c, index 0 is input_a, not the visually first slot on the node.
The index rules worth memorizing
- It counts from 0.
input_a= 0,input_b= 1, and so on. This trips people whose muscle memory says "first = 1." - Negative indices count from the end. -1 is the last connected slot. Handy when you don't know how many are wired.
- Decimals are truncated. 2.7 becomes 2, so you can drive it straight from a float if that's all you have.
- Out of range is your choice. With three slots and index 4:
wrapwraps around to slot 1,clamppins to the last slot (slot 2),errorstops the prompt and tells you.wrapis the right default for a looping stepper;erroris the one you want when a wrong index means a bug you'd rather hear about than silently round into.
Like the other switches in the suite, only the selected input is evaluated - the work behind the other 24 candidate branches is skipped, so you can park genuinely heavy pipelines behind different slots and only pay for the one the index points at.
The outputs that make it a stepper
output is the obvious one. The other two are what turn the node into something programmable:
resolved_index- which slot was actually read after wrap or clamp did its thing. Feed it back into your logic to keep a counter in sync when it runs past the end.count- how many slots are connected. A stepper that increments its own index forever needs to know when to reset, and this is that number.
The natural pairing: Condition Chain → index switch
The pattern the node description points at is the classic if/else chain. Run WAS Condition Chain - which answers the position of the first true condition - straight into this switch's index, and you've built a readable if/else-if/else ladder out of two nodes. Condition A holds → index 0 → input_a answers; condition B holds → index 1 → input_b answers; nothing holds → the chain's fallback → whichever slot you've reserved for the else case. It's the closest ComfyUI plumbing gets to a switch statement, and it stays legible because each branch is still a visible wire.
Installing
Part of WAS Node Suite v3 (WASasquatch/was-node-suite-comfyui), WASasquatch's MIT suite - going since 2023, one of the packs that's been an ecosystem staple since the early days. Logic nodes need nothing extra: no packages, no weights. Requires ComfyUI 0.14.0+ - v3 is written against the newer node backend API, so on an older ComfyUI the whole pack silently fails to register.
Via ComfyUI Manager, search WAS Node Suite v3, or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui
Restart and it shows up under WAS Suite/Logic/Switch. Missing? Update ComfyUI - it's almost always the version, not the install.
Inputs (28)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT,NUMBER,FLOAT | 0-99999999–99999999 | Slot to pass on, from 0. Negative counts from the end: -1 = last. A decimal is truncated: 2.7 = 2. |
| out_of_range | COMBO | wrap | Index outside 0..count-1. With 3 slots and index 4: `wrap` = slot 1, `clamp` = slot 2, `error` stops the prompt. |
| input_aopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_bopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_copt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_dopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_eopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_fopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_gopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_hopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_iopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_jopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_kopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_lopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_mopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_nopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_oopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_popt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_qopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_ropt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_sopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_topt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_uopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_vopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_wopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_xopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_yopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. | |
| input_zopt | COMFY_MATCHTYPE_V3 | One candidate for the index. Any type. The first connection fixes the type; an unconnected slot is not counted, so index 0 is the first slot actually wired. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| output | COMFY_MATCHTYPE_V3 | The selected input, typed to whatever was connected. |
| resolved_index | INT | Slot actually read, from 0, after wrap or clamp. |
| count | INT | Connected slots. The index runs 0..count-1. |