For Loop (Count)
The ComfyUI 'loop' that's secretly just a list — and why that's fine
- index
The name overpromises. "For Loop (Count)" sounds like you're getting a real loop - an iterator with a body, maybe even feedback from one pass to the next. You're not. What SimpleForLoop actually does is output the list [0, 1, 2, …, total-1] and let ComfyUI's own list execution fan your workflow out once per number. Once you stop expecting magic, it turns out that's most of what people want a loop for anyway.
Reach for it whenever you want the same graph run N times with a different value each run. Seed sweeps, prompt variations, "let me try this sampler at five different CFGs," a row of denoise strengths. ComfyUI normally wants each of those hand-wired as its own run; this collapses N runs into bumping one number and pressing Queue.
How it actually works
The trick is a single flag in the node definition, OUTPUT_IS_LIST. ComfyUI sees a Python list on the wire and executes every downstream node once per element. So the "loop" is ComfyUI's built-in batch/list expansion doing the work - the node just manufactures the list of integers to trigger it.
That's also the honest limit: there is no iteration state. Run three doesn't see run two's output, because there's no run three yet when run two starts. Each pass is independent. If you genuinely need the previous iteration's result fed into the next one (chained img2img refinement, that kind of thing), this isn't the tool - you want a stateful loop or a sender/receiver-style construction. For fan-out, this is exactly the cheap, correct tool.
The one input that matters
This is a two-widget node, which is its whole charm:
- total (INT, default 1, min 1, max 100) - how many times you want things to run.
That's it. The output, index, is an INT list containing 0 through total-1. Wire it into anything you want to vary per run - a seed node, a CFG value, a strength slider, a prompt selector. If you need values that aren't just 0..N-1, run the index through a switch or mapping node to translate it.
Concrete: set total to 4, connect index to a seed, Queue, and you get four images, one per seed. That's the whole use case in one sentence.
Install
No ceremony here. ComfyUI Manager → search ComfyUI_LoopNode and install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/t22m003/ComfyUI_LoopNode.git
Restart ComfyUI. There's no requirements.txt, no model downloads, no CUDA-only anything - the code imports nothing beyond Python's stdlib, so it runs on any platform. It shows up under the Loop category.
Where people get burned
- It re-runs everything downstream, per element. Ten iterations on a big img2img chain is ten full passes, not ten cheap ones. That's the real cost and it's easy to forget mid-graph.
- The 100 cap.
totalmaxes out at 100. Need more iterations? The Range sibling in the same pack goes to 10,000, or split the job. - "It's broken, all my images are identical." If you don't actually wire
indexinto something that varies, the loop runs and every output looks the same. The node emits numbers; it's your job to spend them.
One more thing worth knowing: the author's other pack is Linux-leaning and a known Windows headache, but none of that carries over here. This one is pure Python and platform-neutral - probably the most drama-free install you'll do this week.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| total | INT | 11–100 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| index | INT | — |