Nodes/DemonAlone-JS_Addon-ComfyUI/Simple Loop Controller [BETA]
ComfyUI Node

Simple Loop Controller [BETA]

A loop that re-queues itself until it's done — the dumb-simple batch runner

By DemonAlone·Created about a month ago·Updated a day ago· 1
Simple Loop Controller [BETA]
  • any_input
  • output
  • current_step
total1
current_step-1

ComfyUI doesn't do loops natively. If you want "run this same pipeline N times, each pass doing something slightly different," you either batch everything inside one prompt or you build a loop out of pain. SimpleLoopController (display Simple Loop Controller [BETA]) is the second thing made bearable: a counter that runs your workflow, bumps itself, and re-queues the next pass automatically - over and over until it hits total. It's part of DemonAlone-JS_Addon-ComfyUI, the JS companion pack to the main DemonAlone-nodes repo.

How it works

The loop is "loop by re-queue," not a server-side while loop - an important distinction. The Python node holds a step counter. Each execution, it records the current step, computes the next one, and returns next_step and is_finished as UI data. The JS (web/LoopController.js) catches that, writes the next step back into the node's current_step widget, and - if not finished - calls app.queuePrompt(0, 1) to fire the whole workflow again. The graph re-runs from scratch each pass with the new step value; the node's state lives in its widget.

Because state is just a widget value, the loop survives the graph finishing - that's the trick that makes re-queueing work, and it's also why the node carries a 🛑 Abort Loop button. Abort does a two-step interrupt + queue-clear dance and resets the counter back to idle (-1) so a leftover loop doesn't haunt your next run.

The inputs

  • total - how many passes to run (1–100).
  • current_step - the current pass, default -1 = idle. You generally never set this by hand; the node does.
  • any_input - an optional wildcard passthrough. It exists so you can wire the loop node into your data path and keep it in execution order without it meddling with values.

The outputs

  • output - the same any_input value passed through, untouched.
  • current_step - the running step as an INT. This is the useful one: wire it to anything that should vary per pass - a seed, a prompt index, a strength slider. You get 0, 1, 2, ... up to total - 1, then the loop idles.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/DemonAlone/DemonAlone-JS_Addon-ComfyUI

Or grab "DemonAlone-JS_Addon-ComfyUI" from ComfyUI Manager and restart. No models, no dependencies.

Where people get burned

The first is the fundamental one: each pass is a full re-queue, so every iteration reloads models unless you've got them cached, and the whole workflow executes from the top. There's no mid-prompt state carry-over beyond your widgets. For genuinely sequential tasks - per-scene renders, feeding different prompts one at a time - that's fine. For "do 100 variations fast," you'd still rather batch inside a single run.

Second, total caps at 100. That's a real ceiling, and if you hit it you'll be splitting runs.

Third, the loop's self-queueing can interact badly with manual queue management - if you're already running other jobs, the loop will happily re-queue alongside them, and the abort button is the escape hatch. Keep the abort visible and remember it exists. It's a simple tool with a simple failure mode, which is precisely the appeal: no scheduler, no config file, just a counter that politely re-queues itself until the work is done.

Categoryutils/loop

Inputs (3)

NameTypeDefaultDescription
totalINT11–100
current_stepINT-1-1–100
any_inputopt*

Outputs (2)

NameTypeDescription
output*
current_stepINT