Nodes/Boyonodes/Boyo For Loop Start
ComfyUI Node

Boyo For Loop Start

The loop start that replicates EasyUse without making you install EasyUse

By DragonDiffusionbyBoyo·Created 2 years ago·Updated 26 days ago· 16
Boyo For Loop Start
  • initial_value1
  • initial_value2
  • initial_value3
  • initial_value4
  • initial_value5
  • initial_value6
  • initial_value7
  • initial_value8
  • initial_value9
  • flow
  • index
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
total1
loop_id1
reset_signal0

Boyo For Loop Start is the open bracket of a for loop: set a count, feed in some initial values, and let the loop run the graph between it and its matching End node that many times. What makes it worth a second look is the provenance - the source calls it an "exact replication" of EasyUse's forLoopStart, minus the EasyUse dependency. EasyUse's loop nodes are the ones half the community's batch workflows are built on, and this pack reimplements that logic so you get the pattern without installing another pack.

If you've never used a graph loop, the mental model is: put the Start node at the top, the End node at the bottom, and everything wired between them runs once per iteration. Values that need to survive between iterations - a counter, an accumulated latent, a prompt - thread through the loop as pass-through values: they enter the Start, travel down through the loop body, and come back out the End.

How it works

The two inputs that define the loop are total (1–100000, default 1) - the iteration count - and loop_id (1–999, default 1). loop_id is the match key: the Start and End nodes with the same loop_id belong to the same loop, and it's also the key for the internal cache that persists values across iterations. Two loops in one graph need different IDs; forget that and your loops will bleed into each other.

Under the hood it uses ComfyUI's GraphBuilder to expand into a while-loop structure, which is how it gets real looping behavior out of a graph engine that doesn't natively loop. It also carries a reset_signal input (INT): when that value changes, the loop cache is cleared and the loop restarts - that's your "run this loop again from scratch" trigger, and it's the piece that makes chaining multiple loop passes possible.

The initial_value1 through initial_value9 inputs (wildcard-typed) are the pass-through slots: give them starting values, and they flow through the loop. The outputs are flow (the FLOW_CONTROL signal that must connect to the matching End node's flow input), index (INT - the current iteration number, 0-based), and value1value9 (the pass-through values, current state).

Using it

BoyoForLoopStart (total=5, loop_id=1) ──flow──▶ [loop body: sampler, etc.] ──▶ BoyoForLoopEnd (loop_id=1)
        index / value1...                            ▲                                    │
        └────────────────────────────────────────────┴────────────────────────────────────┘

The loop body lives between Start and End; the Start's valueN outputs become the End's valueN outputs after each pass, and re-feeding them keeps state alive. For any batch job - iterate over prompts, generate N images, accumulate latents - this is the node that expresses it.

Installation

Part of Boyonodes, no extra dependencies:

cd ComfyUI/custom_nodes && git clone https://github.com/DragonDiffusionbyBoyo/Boyonodes

restart, find it under Boyo/Logic/For Loop.

Where people get burned

  • Loop never starts / runs once - total left at its default of 1. Set it.
  • Two loops interfering - distinct loop_ids, always.
  • Values resetting between iterations - you're reading the Start's outputs instead of feeding the End's outputs back around. Pass-through values only persist if you actually wire them in a circle.
  • Stuck loop after a change - bump reset_signal to clear the cache; the author built that input precisely because ComfyUI caches aggressively and stale loop state is the usual suspect.

If your loops have been "I copy-paste the same ten nodes ten times," this is the node that ends that. It's a workhorse, not a showpiece - the kind of thing you install once and quietly rely on for every batch workflow after.

CategoryBoyo/Logic/For Loop

Inputs (12)

NameTypeDefaultDescription
totalINT11–100000
loop_idINT11–999
reset_signaloptINT0
initial_value1opt*
initial_value2opt*
initial_value3opt*
initial_value4opt*
initial_value5opt*
initial_value6opt*
initial_value7opt*
initial_value8opt*
initial_value9opt*

Outputs (11)

NameTypeDescription
flowFLOW_CONTROL
indexINT
value1*
value2*
value3*
value4*
value5*
value6*
value7*
value8*
value9*