While Loop End
The node that actually closes a while loop
- flow
- initial_value0
- 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
- value0
- value1
- value2
- value3
- value4
- value5
- value6
- value7
- value8
- value9
- value10
- value11
- value12
- value13
- value14
- value15
- value16
- value17
- value18
- value19
ComfyUI graphs are supposed to be acyclic - data flows one way, no cycles. Which makes "loop until a condition is met" awkward, because that's literally a cycle. yolain's ComfyUI-Easy-Use pack fakes it with a start/end pair, and easy whileLoopEnd is the closing bracket. It's where the loop checks whether to go around again, and where the accumulated values come out when it finally stops.
If you've written a while loop in any language, the mental model transfers cleanly: whileLoopStart opens the block, your nodes in between are the body, and whileLoopEnd evaluates the condition and either loops or exits. The pack markets this as "lazy if/else and for loops," and it's genuinely handy for things a normal graph can't express - iterate until an image passes a check, keep refining until a value settles.
How it works
Two inputs drive it. flow is the FLOW_CONTROL signal from the matching whileLoopStart - that wire is what defines the loop boundary, so it's not optional plumbing, it's the loop itself. condition is a boolean: while it's true, the loop runs again; the moment it's false, the loop ends and the current values are emitted.
Everything else is state you carry around the loop. There are twenty initial_value inputs and twenty matching value outputs, all wildcard-typed (*), so they hold anything - latents, images, counters, strings. You feed a value in, the body transforms it, and it comes back around on the next iteration. When the condition flips false, whatever's in those slots at that moment falls out the outputs. Twenty is the cap (the loop nodes were set to a max of 20 in/out in v1.3.0), which is plenty for most real loops.
The inputs that matter
- condition - the exit test. Wire a boolean that becomes false when you want to stop: a comparison result, the output of
easy isNone, a counter check. Get this wrong and you loop forever or never. - flow - from
whileLoopStart. Just connect it. - initial_value0… / value0… - your loop-carried state, in and out.
Installing it
Comes with the pack. ComfyUI Manager → "ComfyUI Easy Use" → install → restart. Or cd ComfyUI/custom_nodes && git clone https://github.com/yolain/ComfyUI-Easy-Use, run install.bat / pip install -r requirements.txt, restart.
Common issues
The big one, and it's a doozy: an infinite loop will hang or crash ComfyUI. There's no safety net here - if your condition never becomes false, the graph never terminates. Always build in a real stop: a counter that increments each pass and a check that trips it after N iterations, even if your "real" condition is something fuzzier. Test with a low cap first.
Second, whileLoopEnd is useless without its whileLoopStart - the flow wire has to come from a matching start node, and the value slots have to line up between them. Mismatched or missing flow wiring is the usual reason a loop "does nothing" or errors on run. And honestly: while-loops in ComfyUI remain a bit of a power-user feature. If a plain for-loop with a known count fits your problem, use that instead - it's far harder to accidentally wedge.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| flow | FLOW_CONTROL | — | |
| condition | BOOLEAN | — | |
| initial_value0opt | * | — | |
| 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 (20)
| Name | Type | Description |
|---|---|---|
| value0 | * | — |
| value1 | * | — |
| value2 | * | — |
| value3 | * | — |
| value4 | * | — |
| value5 | * | — |
| value6 | * | — |
| value7 | * | — |
| value8 | * | — |
| value9 | * | — |
| value10 | * | — |
| value11 | * | — |
| value12 | * | — |
| value13 | * | — |
| value14 | * | — |
| value15 | * | — |
| value16 | * | — |
| value17 | * | — |
| value18 | * | — |
| value19 | * | — |