Loop Index Switch🐰
Give each loop pass a different input
- default_value
- *
Once you've got a loop running - batch or single, doesn't matter - the next question is usually "okay, but can iteration 0 do something different from iteration 1?" That's what Loop Index Switch is for. It's a router: give it the current iteration_count, right-click to add one input per iteration number you care about, and on each pass it picks whichever input matches and ignores the rest. First iteration runs a Flux Redux path, second runs a Flux Pulid path - that's literally the pack's own example workflow, and it's the kind of thing this node exists for.
How it works
There's no fixed input list here the way most nodes have one - you build it yourself. Right-click the node, choose "Add Loop Input," type the iteration number you want (0 through 99), and a new input slot appears for it. Wire in whatever you want that pass to use: a prompt, a model, a LoRA stack, a number, anything - the input type is a wildcard (*), so it'll take whatever you connect. "Remove Loop Input" undoes it.
Here's the part that actually matters for performance: only the input matching the current iteration gets evaluated. The rest are skipped entirely, not just ignored downstream - the author's own framing for this is "lazy evaluation," and it's a genuine efficiency choice, not just tidiness. That means you can wire five completely different, expensive processing chains into five different iteration slots, and on any given pass only one of them actually runs and costs you time. It's not that ComfyUI is somehow smarter about your whole graph - it's that this node specifically declines to pull results from branches that aren't the active one.
Inputs and outputs
iteration_count(required, INT) - feed this fromCyberEve_BatchImageLoopOpenorCyberEve_SingleImageLoopOpen'siteration_countoutput. This is what the node checks against your numbered inputs.default_value(optional, wildcard) - the fallback used when the current iteration doesn't have a matching numbered input wired up. Worth setting if your loop can run more passes than you've bothered to configure inputs for.- Output: a single wildcard slot carrying whatever value matched for this pass - connect it wherever that per-iteration value needs to go.
Installing it
Comes with the rest of the ComfyUI-Loop-image pack - install once, get all seven nodes. Through ComfyUI Manager: search "ComfyUI-Loop-image", install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/WainWong/ComfyUI-Loop-image
No models, no extra dependencies to speak of - it's pure graph logic. Find it in the CyberEveLoop🐰 category after restart.
Where people get tripped up
The most useful real-world caveat: this isn't a general-purpose list iterator. It's an index dispatcher - you manually wire one input per specific iteration number. Someone in the community asked the pack's author directly whether they could point it at a CSV file and have it walk through the rows; the answer was straightforwardly no. If what you actually want is "iterate over an arbitrary external list," this node isn't that tool - it's for "do one of N pre-wired things depending on which pass I'm on."
Second: if all you need is a different seed on every pass rather than genuinely different logic per iteration, you may not need this node at all. iteration_count from the loop-open node is already just an integer - convert your KSampler's seed widget to an input and wire iteration_count straight into it, and you get a different seed every pass with no switch node in the middle. Save Loop Index Switch for when the branches genuinely diverge (different prompt, different model, different LoRA), not for simple seed variation.
And obviously: without default_value set, an iteration that doesn't have a matching numbered input just has nothing to output for that pass - if something downstream expects a value on every iteration, set the fallback.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| iteration_count | INT | — | |
| default_valueopt | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |