While Loop Start
The gate that lets a ComfyUI loop run
- initial_value_1
- initial_value_2
- initial_value_3
- initial_value_4
- initial_value_5
- initial_value_6
- initial_value_7
- initial_value_8
- initial_value_9
- initial_value_10
- initial_value_11
- initial_value_12
- initial_value_13
- initial_value_14
- initial_value_15
- initial_value_16
- initial_value_17
- initial_value_18
- initial_value_19
- initial_value_20
- flow
- 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
- value_20
ComfyUI has no real while loop in core. You can hand-unroll a few copies of your sampler or lean on Impact Pack's iteration tricks, but a proper "keep doing this until a condition stops being true" loop has always been a custom-node thing. PixNodes' While Loop Start is the top half of that loop - the node that opens the gate, carries the loop's values down the line, and can slam the gate shut.
It always pairs with Pix_WhileLoopEnd. The Start marks the top of the loop body; the End decides whether to run it again. Everything you want repeated - an image edit, a sampler pass, an LLM call, whatever - sits between the two, wired Start's flow to End's flow, with data flowing through the value slots. The pack's README credits rgthree-comfy and ComfyUI-Easy-Use as the design inspiration, which tells you the family it belongs to: graph-level control flow, not pixel work.
How it works
The one thing that decides whether the loop runs at all is condition, a BOOLEAN that defaults to true. When it's true, the node passes its initial_value_1..20 straight through as value_1..20 - the loop body gets this iteration's values. When it's false, every value output returns an ExecutionBlocker(None), ComfyUI's built-in "skip this whole branch" signal, so the body below never executes. That's the loop failing safe: a false condition at the top means "don't even start," and nothing downstream runs or errors.
The inputs and outputs that matter
- condition (BOOLEAN, default true) - the gate. Feed it a comparison (this pack's Pix_Compare, or any boolean-producing node) rather than leaving it stuck at true forever, or you'll never stop looping.
- initial_value_1 through initial_value_20 (any type) - the loop's working state: a counter, a latent, a string, whatever you need to carry per iteration. Only the ones you actually wire matter.
- flow (FLOW_CONTROL) + value_1..20 - flow connects to the End's flow input; the values are what the loop body consumes.
A bundled JS extension hides the unused slots and auto-creates a matching output whenever you connect an input, so you see a tidy little node instead of 20 empty sockets. One inconsistency worth knowing: the pack's own web docs still say slots start at initial_value_0, but the shipped code is 1-based - trust what's on the canvas.
The classic shape is a counter loop: feed 0 into initial_value_1, add 1 with Pix_MathInt inside the body, compare the result against your target with Pix_Compare, and wire that boolean to the condition. The End re-feeds the updated values to the Start each pass, which is what turns a graph into something that iterates.
Install
Part of Comfyui-PixNodes - no models, light dependencies (openai and requests, neither needed for loops). Easiest via ComfyUI Manager: search PixNodes, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/pixixai/Comfyui-PixNodes
cd Comfyui-PixNodes
pip install -r requirements.txt
Then restart. Heads-up: the README's manual-install section copy-pastes a different repo's URL (ComfyUI-AlignLayout). Use the one above.
Gotchas
Two things get people. First, the changelog entry for v1.1.0 (March 2026) literally says "fixed loop nodes' data not being transmitted" - if your loop values come back empty or null, you're on an old build; update the pack. Second, remember the loop unrolls: every iteration adds another copy of the body to the executed graph, so a long loop of heavy nodes gets slow and VRAM-hungry fast. Keep the body lean and put a hard cap in the condition even if you expect to break out early.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | true | — |
| initial_value_1opt | * | — | |
| initial_value_2opt | * | — | |
| initial_value_3opt | * | — | |
| initial_value_4opt | * | — | |
| initial_value_5opt | * | — | |
| initial_value_6opt | * | — | |
| initial_value_7opt | * | — | |
| initial_value_8opt | * | — | |
| initial_value_9opt | * | — | |
| initial_value_10opt | * | — | |
| initial_value_11opt | * | — | |
| initial_value_12opt | * | — | |
| initial_value_13opt | * | — | |
| initial_value_14opt | * | — | |
| initial_value_15opt | * | — | |
| initial_value_16opt | * | — | |
| initial_value_17opt | * | — | |
| initial_value_18opt | * | — | |
| initial_value_19opt | * | — | |
| initial_value_20opt | * | — |
Outputs (21)
| Name | Type | Description |
|---|---|---|
| flow | FLOW_CONTROL | — |
| 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 | * | — |
| value_20 | * | — |