For Loop End
Where your for loop actually finishes
- flow
- value0
- value1
- value2
- value3
- value4
- value5
- value6
- value7
- value8
- value9
- value0
- value1
- value2
- value3
- value4
- value5
- value6
- value7
- value8
- value9
For Loop End is the second half of the pack's for loop, and it does a genuinely clever thing that most ComfyUI loop hacks don't: it actually iterates. You connect its flow input to For Loop Start's flow output, run your workflow body in between, and this node feeds your values back into the next iteration until the count is hit. Then it hands you the final results. Same shape as a for loop in any language - except it's built out of graph expansion instead of real control flow.
How it works
ComfyUI's execution engine doesn't natively support loops, so this node cheats in the sanctioned way. The flow value from For Loop Start carries the start node's ID and the total count. Each time For Loop End runs, it reads the current iteration index off the start node, and if more iterations remain, it uses ComfyUI's GraphBuilder API to expand the graph - copying everything between start and end, bumping the index, feeding the new values into the copy, and scheduling the whole thing to run again. When the index reaches count, it stops expanding and returns the accumulated values.
The practical upshot: the values you plug into For Loop End's value0 through value9 inputs become the next iteration's value0-value9 on For Loop Start. That's how you accumulate results across passes, and it's why the loop body needs to run between the two nodes, not off to the side.
Inputs and outputs
flow(required) - wire from For Loop Start'sflow. This is what ties the pair together.value0–value9(optional, any type) - the values to carry forward. The slots are dynamic: they show up as you connect things.
Outputs are value0 through value9 - the final values after the last iteration. Wire them into whatever consumes the loop's result: a save node, a prompt, a sampler. Any type works, so you can pass images, latents, strings, or numbers through.
Common gotchas
The whole pack installs in one go - ComfyUI Manager, search "Latent Astronaut Suite," or:
cd ComfyUI/custom_nodes
git clone https://github.com/latentastronaut/comfyui-latent-astronaut-suite
then restart. No extra Python dependencies for the loop nodes; the pack's other features (LLM, ChatterBox) pull theirs at install time, but loops run on stock ComfyUI.
Where people get burned: forgetting to connect flow at all (the pair just won't work), or connecting For Loop End's output back into something inside the loop body instead of after it. Also keep count sane - the node caps at 10000, but each iteration duplicates your whole loop body in the graph, so huge counts plus heavy bodies is a fast way to eat RAM. And because loops rely on graph expansion, they work best on current ComfyUI builds; very old versions may not support the expand API.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| flow | FOR_LOOP_FLOW | Connect from ForLoopStart's flow | |
| value0opt | * | — | |
| value1opt | * | — | |
| value2opt | * | — | |
| value3opt | * | — | |
| value4opt | * | — | |
| value5opt | * | — | |
| value6opt | * | — | |
| value7opt | * | — | |
| value8opt | * | — | |
| value9opt | * | — |
Outputs (10)
| Name | Type | Description |
|---|---|---|
| value0 | * | — |
| value1 | * | — |
| value2 | * | — |
| value3 | * | — |
| value4 | * | — |
| value5 | * | — |
| value6 | * | — |
| value7 | * | — |
| value8 | * | — |
| value9 | * | — |