π° For Loop While Open - v1 /l
The low-level loop opener β for when 'loop N times' isn't enough
- initial_value0
- initial_value1
- initial_value2
- initial_value3
- initial_value4
- FLOW_CONTROL
- value0
- value1
- value2
- value3
- value4
The friendly For Loop Open node you drag onto a canvas is actually a wrapper that instantiates this node internally. For Loop While Open is the raw primitive: the start marker of a while-style loop, with a condition that decides whether the loop body should run at all. You reach for it directly when you want a loop that runs "until a condition changes" rather than a fixed "N times."
It pairs with For Loop While Close. Open hands you a flow_control wire plus up to five carried values; you build your loop body; Close at the far end reads a condition and either re-runs or stops.
How it works
On the surface it's almost embarrassingly simple: condition is a BOOLEAN (default true), and the node's outputs are a FLOW_CONTROL wire plus value0β¦value4, which are just your initial_value0β¦initial_value4 passed through. All the looping intelligence lives in the matching While Close node - Open just marks the boundary and carries the values. That's the actual design: Open is a passive gate, Close is the engine.
The hidden twist is that For Loop Open (the high-level one) uses this node with condition set to the remaining counter, which is how the "N times" loop is really a while loop under the hood: remaining > 0 is the condition, and Close decrements it each pass.
Inputs: condition (BOOLEAN, default true), initial_value0β¦initial_value4 (optional, any type). Outputs: FLOW_CONTROL, value0β¦value4.
Why you'd hand-build one
Fixed-iteration loops cover most needs, but "loop until this mask is fully processed" or "loop until the counter reaches a target computed at runtime" don't. With the raw pair you wire your own stopping rule into While Close's condition, and the Open node just needs to exist as the boundary. It's also the node to understand first if you're ever confused by the high-level loop - everything you see there is this node plus the math nodes dressed up.
Installing it
Ships in the MaraScott pack: ComfyUI Manager β search "MaraScott" β Install β restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MaraScott/ComfyUI_MaraScott_Nodes
Then restart. Standard pack caveats: heavy requirements (transformers==4.37.2 pinned, opencv-python, numba, blend_modes) for what is functionally a boundary marker.
Common issues
Since Open is passive, most failure modes come from its partner. If a hand-built while loop never starts, check that the condition feeding Close isn't wired backwards or fed from a widget that forces it true. If it never stops, nothing inside the body is changing the condition's source - same hazard as any while loop anywhere. And for both of these nodes, keep ComfyUI updated: the whole loop system depends on dynamic graph expansion, which isn't available in ancient cores.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | true | β |
| initial_value0opt | * | β | |
| initial_value1opt | * | β | |
| initial_value2opt | * | β | |
| initial_value3opt | * | β | |
| initial_value4opt | * | β |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| FLOW_CONTROL | FLOW_CONTROL | β |
| value0 | * | β |
| value1 | * | β |
| value2 | * | β |
| value3 | * | β |
| value4 | * | β |