Switch N (NH)
Pick one of ten inputs by index, with a safe fallback
- input_0
- input_1
- input_2
- input_3
- input_4
- input_5
- input_6
- input_7
- input_8
- input_9
- result
- count
Sometimes a boolean switch isn't enough. You've got three checkpoints, five styles, eight prompts, and you want to point an index at whichever one is active this run. Switch N (NH) is the multi-way version: up to ten inputs (input_0 through input_9), one index, one output. The * wildcard type means those inputs can be anything - models, images, strings, latents - so the same node routes models between two loaders or picks one prompt out of ten.
The mechanic is as simple as it looks: result is whatever input sits at index. All the inputs are optional and unconnected ones just don't exist. The interesting bit is the fallback. If you point the index at a slot that isn't connected, the node doesn't error out or return None - it prints a warning to the console and returns the first connected input instead. So a workflow with only input_0 and input_3 connected, driven with index 5, will silently hand you input_0. That's a deliberate choice in the source, and it's a good one for robustness, but it can hide a mistake: an index that's wrong-but-connected will pass data through looking fine, while an index that's wrong-and-empty quietly falls back. Wire count (the number of connected inputs) into a display or a comparison if you want to keep an eye on what's actually live.
Driving the index
The index is an INT widget, but it also converts to an input socket, which is where this node gets interesting. Drive it from a Random Choice, a math node, a scheduler, or a counter and you've got programmatic routing: a prompt-rotation workflow can cycle a switch through different prompt inputs, or a batch loop can step through a set of model loaders. Because the switch itself has no state and no per-run logic, ComfyUI caches it normally - only the source of the index needs to change to re-fire it.
The honest limits: ten inputs, one selection, no weighting. If you need weighted randomness across slots, that's Random Choice (NH), not this. If you need to select by value rather than position (find the slot containing a certain string), you want a match-index node. Switch N is the plain, predictable "give me slot N" tool, and it's better at that than most alternatives.
Install
It's part of NH-Nodes:
- ComfyUI Manager → search NH-Nodes → install → restart ComfyUI. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Then restart ComfyUI.
Logic node, no models, nothing heavy.
Common issues
The fallback behavior is the thing to internalize: an out-of-range index returns the first connected input, not an error. If a workflow "always shows input_0" no matter the index, you've probably got an index pointing at an empty slot. And if result is None, you've connected no inputs at all - the node warns to the console and hands back nothing. Keep count visible during setup and you'll catch both cases in seconds.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 00–9 | — |
| input_0opt | * | — | |
| input_1opt | * | — | |
| input_2opt | * | — | |
| input_3opt | * | — | |
| input_4opt | * | — | |
| input_5opt | * | — | |
| input_6opt | * | — | |
| input_7opt | * | — | |
| input_8opt | * | — | |
| input_9opt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result | * | — |
| count | INT | — |