Nodes/Kinburg-Nodes/Repeat (Open)
ComfyUI Node

Repeat (Open)

Real counted loops with state, inside an acyclic graph

By Kinburg·Created 3 months ago·Updated 6 days ago· 1
Repeat (Open)
  • 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
count4

ComfyUI's execution graph is acyclic, which is normally a feature - but it means "run this block of nodes N times and feed each iteration's output into the next" isn't something you can just draw. Repeat (Open) is the top of a real counted loop, and it works by expanding the graph at queue time: each pass, the matching Repeat (Close) clones the whole loop body, wires it back into the next iteration, and runs it all inside one queue run. You get a genuine for i in range(count) with carried state, in a tool that wasn't built for loops at all.

How it's used

The pattern is: wire starting values into Repeat (Open)'s wildcard value_* inputs, read index inside the loop body, do your work, and feed the updated values back into Repeat (Close)'s value_* inputs. After count iterations, Close outputs the final state.

The smart move is the 🔗 Add / link Close button on the Open node - it spawns the matching Close and wires the flow and index links for you, so you never hand-draw the feedback loop. flow is the internal KINBURG_LOOP_FLOW token the Close node reads to find its Open, and index is the current iteration number (wire it to the Close's index input - the Auto-pair button does this too).

Two details from the source worth knowing:

  • count must stay a widget value, not an input - it's read at expansion time, before the run, so converting it to an input will break the loop. Keep it typed on the node.
  • The value_* slots are wildcard (*) and auto-growing: the node shows only connected slots plus a spare, and any type - IMAGE, LATENT, STRING, a list - works. They're also how state carries: whatever you feed into Close comes back out of the next iteration's Open.

When you'd reach for it

For each / collection loops where you need the previous iteration's result - a chain of img2img passes, an accumulator building up over N steps, a progressive upscale loop where each pass refines the last output. That's the "carried state" distinction: a plain map-over-a-list is For Each's job; Repeat is for feedback, where iteration N's output feeds iteration N+1's input. If the body doesn't depend on the previous pass, use For Each and keep things simple.

Installing it

It ships in Kinburg/Kinburg-Nodes - ComfyUI Manager search "Kinburg-Nodes", or cd ComfyUI/custom_nodes && git clone https://github.com/Kinburg/Kinburg-Nodes, restart. No dependencies, no models, pure graph machinery. Same pack also has While (Open)/While (Close) for condition-driven loops on the same engine, and Delay if you want to slow iterations down and watch them run. Start with a small count - a runaway loop is a polite way to burn an afternoon.

CategoryKinburg-Nodes/flow/loops

Inputs (21)

NameTypeDefaultDescription
countINT41–100000How many times the loop body runs. Keep this a value (not an input) — it's read at expansion time.
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)

NameTypeDescription
flowKINBURG_LOOP_FLOW
indexINT
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*