Nodes/ComfyUI Easy Use/For Loop End
ComfyUI Node Runs on cloud

For Loop End

Close a for-loop and collect its results

By yolain·Created 3 years ago·Updated 9 days ago· 2,633
For Loop End
  • flow
  • initial_value1
  • initial_value2
  • initial_value3
  • initial_value4
  • initial_value5
  • initial_value6
  • initial_value7
  • initial_value8
  • initial_value9
  • initial_value10
  • initial_value11
  • initial_value12
  • initial_value13
  • initial_value14
  • initial_value15
  • initial_value16
  • initial_value17
  • initial_value18
  • initial_value19
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
  • value10
  • value11
  • value12
  • value13
  • value14
  • value15
  • value16
  • value17
  • value18
  • value19

This is the bottom bracket of a loop. On its own it does nothing interesting - its whole job is to sit at the end of a repeating section and tell ComfyUI "go back and do that again until we're done." It's always used as a pair: a loop-start node (easy forLoopStart, or easy loadImagesForLoop) opens the loop, your processing sits in the middle, and easy forLoopEnd closes it. ComfyUI itself has no built-in looping, so this pair is how you get one.

Why you'd reach for it

Looping unlocks the batch jobs a single-pass graph can't express cleanly:

  • Run the same processing over every image in a folder (with easy loadImagesForLoop as the start).
  • Generate N variations by iterating a counter and feeding it to a seed or an index switch.
  • Iteratively refine - feed each pass's output back as the next pass's input, N times.

The key idea is the carried values. A loop usually needs to remember something between iterations: an accumulating list of results, a running total, the image from the previous pass. easy forLoopEnd is where those values loop back around. You wire what you want to carry into its initial_value sockets, and it feeds them back to the loop-start for the next round.

The inputs and outputs

  • flow (FLOW_CONTROL, required) - the loop-control signal from the matching loop-start node. This connection is the loop; without it, there's nothing to close.
  • initial_value1 … initial_value19 (any, optional) - the values you want carried across iterations. Wire your per-pass results (an updated list, a counter, the latest image) into these.
  • value1 … value19 (any) - the corresponding outputs, available once the loop completes, holding the final carried values.

You don't need all 19 - connect as many value channels as your loop actually accumulates. Most loops use one or two.

Installing it

ComfyUI Manager: search ComfyUI Easy Use, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/yolain/ComfyUI-Easy-Use

then install the requirements (install.bat on Windows, else pip install -r ComfyUI-Easy-Use/requirements.txt) and restart.

Common issues

  • The flow wire is non-negotiable. easy forLoopEnd must be connected to a loop-start via flow. A dangling end node, or one wired to the wrong start, is the most common reason a "loop" runs once or errors.
  • Match the value channels end to end. A value you carry has to line up between the start and end nodes - value1 at the end pairs with the corresponding channel at the start. Cross them and the wrong data circulates.
  • Loops multiply cost. Everything inside the loop body runs once per iteration, so a slow inner workflow times N iterations is exactly that slow. Test with a small iteration count first.
  • Accumulate deliberately. If you want to keep every iteration's result, you have to build that up through the carried values (e.g. append to a list each pass) - the loop doesn't magically collect outputs for you. Save inside the loop body if you just want files on disk.
CategoryEasyUse/Logic/For Loop

Inputs (20)

NameTypeDefaultDescription
flowFLOW_CONTROL
initial_value1opt*
initial_value2opt*
initial_value3opt*
initial_value4opt*
initial_value5opt*
initial_value6opt*
initial_value7opt*
initial_value8opt*
initial_value9opt*
initial_value10opt*
initial_value11opt*
initial_value12opt*
initial_value13opt*
initial_value14opt*
initial_value15opt*
initial_value16opt*
initial_value17opt*
initial_value18opt*
initial_value19opt*

Outputs (19)

NameTypeDescription
value1*
value2*
value3*
value4*
value5*
value6*
value7*
value8*
value9*
value10*
value11*
value12*
value13*
value14*
value15*
value16*
value17*
value18*
value19*