Lazy Index Switch
A 20-way switch that only evaluates the branch you actually pick
- input_0
- 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
- selected
An "index switch" is one of those boring utility nodes you don't think about until you need it: you've got up to twenty candidate inputs - models, prompts, LoRA stacks, whatever - and you want exactly one to flow through based on a number. The classic trap with naive switches is that ComfyUI evaluates everything feeding the switch, even the branches you didn't pick. Expensive branches get computed anyway, and if an unpicked branch is broken, the whole graph fails.
Lazy Index Switch fixes that with actual lazy evaluation. It picks one of input_0 through input_19 by a zero-based index, and only the selected branch gets evaluated.
How it works
The node declares its twenty inputs with the lazy flag, which tells ComfyUI's scheduler to defer them. A check_lazy_status hook then reports back "I only need input_N" - where N comes from the index value - and ComfyUI computes just that branch. If the selected input isn't connected, you get a clear validation error instead of a silent None flowing through the graph.
It accepts any type on its inputs (*), so it's type-agnostic: models, conditioning, images, strings, you name it. And index is an INT socket, not a hardcoded widget, which is the other half of the trick.
The inputs that matter
index- zero-based, 0–19. This pairs with theINDEXoutput that ComfyUI combo nodes expose - wire a combo's INDEX straight in and the switch follows your selection automatically.input_0…input_19- the candidates. Any type, any count; leave the rest unconnected.
Output: selected, the single chosen value.
Install
Part of the Enviral Design Node Pack. ComfyUI Manager: search "Enviral Design Node Pack". Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/EnviralDesign/comfyUI-enviral-design-node-pack
then restart. No extra dependencies.
When you'd reach for it
Two strong cases. First, a menu of heavy options - a "pick your model" dropdown where each entry is a different loaded pipeline. Lazy evaluation means only the chosen pipeline's cost is paid. Second, workflow compaction: twenty potential prompt variants, one switch, one KSampler, instead of twenty duplicated sampler subgraphs. If you've used a non-lazy switch and wondered why your whole graph runs every pass, this is the fix. If your inputs are all cheap, the lazy part matters less - but the INDEX-from-combo wiring alone makes it nicer than a hand-typed index.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| index | INT | 00–19 | Zero-based input index to select. This matches the INDEX output from ComfyUI combo nodes. |
| input_0opt | * | — | |
| 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 | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| selected | * | — |