While (Open)
A Loop That Runs Until You Say Stop — Not a Fixed Count
- value_0
- value_1
- value_2
- value_3
- value_4
- value_5
- value_6
- value_7
- value_8
- value_9
- value_10
- value_11
- value_12
- value_13
- value_14
- value_15
- value_16
- value_17
- value_18
- value_19
- flow
- index
- value_0
- value_1
- value_2
- value_3
- value_4
- value_5
- value_6
- value_7
- value_8
- value_9
- value_10
- value_11
- value_12
- value_13
- value_14
- value_15
- value_16
- value_17
- value_18
- value_19
ComfyUI's execution graph is acyclic, which is a fancy way of saying "no loops" - and then every workflow builder hits the wall where they need one. While (Open) is the top half of the pack's condition-driven loop: the half that starts the iteration, carries state through the body, and hands the updated values back to its Close sibling. Same graph-expansion engine as the pack's Repeat loops, but driven by a condition instead of a count.
How it works
Wire your starting values into the auto-growing value_0 … value_19 slots (wildcard * - drag in any type, images, latents, strings, ints; a matching slot appears), and the Open node emits flow, index, and the current value_* for each pass. The body of your loop builds off those outputs - you read index to know which iteration you're on, compute your next state, and feed the updated values into the matching While (Close). Close clones the whole loop body back into the next iteration, all inside one queue run.
The one hard rule: max_iterations is your safety cap. The loop can't run more than this many times even if the condition stays True. Keep it a widget value, not a wired input - it's read when the loop expands, and an infinite loop in a graph that literally cannot branch is how you end up staring at a frozen queue. Set it to something sane for the work (say, the number of refinement passes you'd ever want) and let the condition do the real stopping.
When to reach for it
The condition-driven shape is for "keep going until it's good enough" rather than "do exactly N times." Refine-until-passing loops, iterating on a seed until a quality check passes, walking a batch until a length threshold - that's where a while beats a repeat. The pack's docs call out the pair as the same engine as Repeat with a boolean condition swapped in for the counter, and there's an Add / link Close button on the node that spawns the matching Close and wires the flow and index links for you - use it, hand-drawing the feedback links is where loops get confusing.
Install
Part of the Kinburg-Nodes pack: ComfyUI Manager (search "Kinburg-Nodes"), or cd ComfyUI/custom_nodes && git clone https://github.com/Kinburg/Kinburg-Nodes, then restart. It's a pure control-flow node - no dependencies, no models, nothing to download. If your workflow is a single pass and never iterates, you don't need this; the moment you catch yourself copy-pasting a subgraph three times and changing a seed, you do.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| max_iterations | INT | 1001–100000 | Safety cap: the loop can't run more than this many times even if the condition stays True. Keep it a value (read when the loop expands). |
| value_0opt | * | — | |
| value_1opt | * | — | |
| value_2opt | * | — | |
| value_3opt | * | — | |
| value_4opt | * | — | |
| value_5opt | * | — | |
| value_6opt | * | — | |
| value_7opt | * | — | |
| value_8opt | * | — | |
| value_9opt | * | — | |
| value_10opt | * | — | |
| value_11opt | * | — | |
| value_12opt | * | — | |
| value_13opt | * | — | |
| value_14opt | * | — | |
| value_15opt | * | — | |
| value_16opt | * | — | |
| value_17opt | * | — | |
| value_18opt | * | — | |
| value_19opt | * | — |
Outputs (22)
| Name | Type | Description |
|---|---|---|
| flow | KINBURG_LOOP_FLOW | — |
| index | INT | — |
| value_0 | * | — |
| value_1 | * | — |
| value_2 | * | — |
| value_3 | * | — |
| value_4 | * | — |
| value_5 | * | — |
| value_6 | * | — |
| value_7 | * | — |
| value_8 | * | — |
| value_9 | * | — |
| value_10 | * | — |
| value_11 | * | — |
| value_12 | * | — |
| value_13 | * | — |
| value_14 | * | — |
| value_15 | * | — |
| value_16 | * | — |
| value_17 | * | — |
| value_18 | * | — |
| value_19 | * | — |