For Loop Open
An actual loop — repeat a slice of the graph N times
- value_1
- value_2
- value_3
- value_4
- value_5
- value_6
- value_7
- value_8
- iterator
- index
- metadata
- value_1
- value_2
- value_3
- value_4
- value_5
- value_6
- value_7
- value_8
Core ComfyUI is a DAG - data flows one way, no node ever runs twice. That's great for diffusion pipelines and a wall the moment you want to do something n times: process every file in a folder, run a denoise pass ten times carrying state between runs, or step a value through a sequence. WAS For Loop Open is half of the pack's answer - the "repeat this part of the graph" node. Pair it with For Loop Close and the slice of graph between them runs again and again, with values carried forward each iteration.
Its natural partner in crime is WAS Directory Listing: list a folder, wire the paths into this loop's body, and you've just turned "I will type these twenty filenames by hand" into "loop over the directory."
How it works - the mode and the counter
A loop needs to know when to stop, and this node gives you two ways to decide:
mode: iterations- runs a fixed count, set withiterations(1 to 10000). The simple, predictable mode.mode: total_frames- runs until For Loop Close has collectedtotal_framesframes. This is the video/animation mode: you don't count loop passes, you count output frames, and the loop keeps going until that pile reaches the target. Two guards keep it sane -max_iterationsis a safety limit that stops the loop even if the frame target is never reached, and total_frames mode needs accumulate switched on at the Close end for frames to be collected at all.
Whatever the mode, start sets the first value of index, the loop's counter. Index starts there and counts up by one each iteration - wire it into a Text List Get and you've got "give me entry 0, then entry 1, then entry 2…".
The value slots - how state survives the trip
This is the part that confuses people coming from a normal programming language, because a graph has no variables. The answer is the value slots: value_1 through value_8 on the Open node, mirrored on the Close node. A slot starts with whatever you hand it; inside the loop you read it out, transform it, hand the result to For Loop Close's matching slot; and next iteration For Loop Open's value_1 holds what Close received. That's the loop's state, flowing around the circle. A new slot appears as you wire one, and you can carry anything - images, latents, numbers, text.
The output worth naming: iterator, a WAS_LOOP value that identifies the loop and where it's up to. Wire it straight to For Loop Close's iterator input and nothing else - that connection is what tells Close which Open it belongs to, and it's the one wire you must not improvise with.
Installing it
WAS Node Suite v3: ComfyUI Manager → search WAS Node Suite v3, or clone into custom_nodes, restart. No models, no dependencies.
Two failure modes worth knowing before you queue something ambitious. In total_frames mode, forget to enable accumulate on the Close node and frames are never collected - the loop relies on max_iterations to save you. And remember only nodes wired back to Close re-run each iteration; anything hanging off the Open node outside that loop runs once, which is how you accidentally compute something once and assume it ran n times. Wire the loop body deliberately, and the Open node's index output is your best friend for debugging what iteration you're on.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | How the loop decides when to stop; COMBO. 'iterations' runs a fixed count; 'total_frames' runs until For Loop Close has collected total_frames frames. | |
| iterations | INT | 101–10000 | Iterations to run in 'iterations' mode; INT, 1 to 10000. Ignored in 'total_frames' mode. |
| total_frames | INT | 1001–1000000 | Frames to collect before stopping in 'total_frames' mode; INT. Counted from what For Loop Close collects, which needs accumulate on. |
| max_iterations | INT | 1001–10000 | Safety limit for 'total_frames' mode; INT, 1 to 10000. Stops the loop even when the frame target is never reached. |
| start | INT | 0-999999–999999 | First value of index; INT. index counts up by 1 from here each iteration, for reading a position in a list. |
| value_1opt | COMFY_MATCHTYPE_V3 | The value slot 1 starts with; any type. Read it back out of value_1 and hand the changed one to For Loop Close's value_1. | |
| value_2opt | COMFY_MATCHTYPE_V3 | The value slot {n} starts with; any type. A new slot appears as this one is wired. | |
| value_3opt | COMFY_MATCHTYPE_V3 | The value slot {n} starts with; any type. A new slot appears as this one is wired. | |
| value_4opt | COMFY_MATCHTYPE_V3 | The value slot {n} starts with; any type. A new slot appears as this one is wired. | |
| value_5opt | COMFY_MATCHTYPE_V3 | The value slot {n} starts with; any type. A new slot appears as this one is wired. | |
| value_6opt | COMFY_MATCHTYPE_V3 | The value slot {n} starts with; any type. A new slot appears as this one is wired. | |
| value_7opt | COMFY_MATCHTYPE_V3 | The value slot {n} starts with; any type. A new slot appears as this one is wired. | |
| value_8opt | COMFY_MATCHTYPE_V3 | The value slot {n} starts with; any type. A new slot appears as this one is wired. |
Outputs (11)
| Name | Type | Description |
|---|---|---|
| iterator | WAS_LOOP | Identifies the loop and where it is up to; WAS_LOOP. Wire it straight to For Loop Close's iterator input, and nothing else. |
| index | INT | The loop's counter; INT. Starts at start and counts up by 1 each iteration, for reading a position in a list. |
| metadata | DICT | This iteration's counters as one value; DICT. Read them with Loop Metadata: current_iteration, index, and the frames collected so far. |
| value_1 | COMFY_MATCHTYPE_V3 | Slot 1 as this iteration receives it; any type. The starting value on iteration 1, then whatever For Loop Close was given last iteration. |
| value_2 | COMFY_MATCHTYPE_V3 | Slot {n} as this iteration receives it; any type. |
| value_3 | COMFY_MATCHTYPE_V3 | Slot {n} as this iteration receives it; any type. |
| value_4 | COMFY_MATCHTYPE_V3 | Slot {n} as this iteration receives it; any type. |
| value_5 | COMFY_MATCHTYPE_V3 | Slot {n} as this iteration receives it; any type. |
| value_6 | COMFY_MATCHTYPE_V3 | Slot {n} as this iteration receives it; any type. |
| value_7 | COMFY_MATCHTYPE_V3 | Slot {n} as this iteration receives it; any type. |
| value_8 | COMFY_MATCHTYPE_V3 | Slot {n} as this iteration receives it; any type. |