ComfyUI Node

For Open

Finally, a real for-loop that runs inside one Queue Prompt

By jeankassio·Created 2 months ago·Updated 2 months ago· 2
For Open
  • initial_value
  • flow
  • index
  • value
start0
end10
_i0

You've done it a hundred times: generated one image, liked the direction, then sat there re-queueing with a new seed or a new prompt until you had a grid of variations. That's a for-loop performed by hand. JkForOpen is the actual loop. Pair it with its matching For Close node and ComfyUI will repeat whatever sits between them - including the Save Image node - all inside a single Queue Prompt press. No scripting, no external tools, no "run this workflow N times" hacks.

It's part of ComfyUI-ForLoops (the JkNodes category), a small pack by Brazilian dev Jean Kassio. The pack is new - first commit June 2026, announced on r/comfyui with exactly zero comments - so it's not battle-hardened yet, but the mechanism underneath it is the one ComfyUI's own devs use in their official loop examples, which is about as solid a foundation as this ecosystem offers.

How it works

JkForOpen behaves like Python's range(start, end). It outputs an index that counts start, start + 1, … end - 1 - end is exclusive, so start=0, end=5 gives you 0,1,2,3,4 (five iterations). Internally it hands a small flow object to the Close node carrying the current iteration count and total, and the Close node clones your loop body and re-runs it for each pass using ComfyUI's graph-expansion engine (comfy_execution.graph_utils.GraphBuilder). That's the magic: the whole loop is expanded and executed as one graph, in one Queue Prompt, rather than by scripting multiple queue submissions.

The inputs and outputs that matter

  • start - first integer index emits (default 0).
  • end - stop value, exclusive (default 10). This is the one you'll actually touch: set it to the number of iterations you want.
  • initial_value (optional) - a starting value threaded through the loop and returned by For Close. Skip it for a plain counting loop.
  • index (output) - the current counter. Feed this into a text loader, a seed node, a prompt - whatever varies per iteration.
  • value (output) - the accumulator, if you threaded one in.
  • flow (output) - connect this to For Close → flow. It's typed JK_FOR_FLOW, so it won't plug into a For Each Close; that mismatch is deliberate, to stop you wiring incompatible pairs.

There's also a hidden _i counter input that the bundled JavaScript strips off the node - you never touch it, it's just how the loop state moves between iterations.

Installing it

ComfyUI Manager is the easy path - search for "ComfyUI-ForLoops" and hit install, then restart. Or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/jeankassio/ComfyUI-ForLoops

Restart ComfyUI. That's the whole install: no requirements.txt, no models to download, no heavy Python deps. The pack is a single nodes.py plus a bit of frontend JS, so it's genuinely zero-friction - a nice change from the "90% of my time is installing missing nodes" problem the ecosystem is known for.

Wiring your first loop

For Open ──flow──────────► For Close
        └─index─► [ load line → generate → Save Image ]

Connect Open's flow to Close's flow, drive your pipeline off index, and put a Save Image at the end. Because everything downstream of the Open node gets repeated, that Save Image fires once per iteration.

Where people get burned

  • end exclusive + end <= start means zero iterations. N lines in a file? Set end = N to get indices 0…N-1. If the loop silently does nothing, check your range.
  • Everything downstream of Open repeats - including expensive stuff. If you meant to run an upscaler once, keep it before the Open node, not after. The loop doesn't know what you intended.
  • It's a young pack. One commit, one author, no community troubleshooting to lean on. If it misbehaves, the source is a single readable file - worth a peek.
CategoryJkNodes

Inputs (4)

NameTypeDefaultDescription
startINT0-2147483647–2147483647First integer emitted by 'index'.
endINT10-2147483647–2147483647Stop value (exclusive), like Python range(start, end). start=0, end=5 -> 0,1,2,3,4.
initial_valueopt*Optional starting value threaded through the loop and returned by For Close.
_ioptINT0

Outputs (3)

NameTypeDescription
flowJK_FOR_FLOW
indexINT
value*