ComfyUI Node

♻ Loop

Loop (Bjornulf_custom_nodes) — ComfyUI Node Guide

By justUmen·Created 2 years ago·Updated about a year ago· 545
♻ Loop
  • input
  • output
nb_loops1
default_textDefault input

This is Bjornulf's original, general-purpose loop node - the one that predates all the type-specific loops (integer, float, images, lines) that the pack now offers. It's the "connect it between literally anything" version: no type checking, no dedicated logic for text vs. numbers vs. images, just an explicit loop count and whatever value you want repeated.

There's a piece of history worth knowing before you use it. Earlier in the pack's life, this exact node broke - a ComfyUI core-engine change stopped allowing a node to output the same cached value twice in a row, which is how the original version of this loop worked. The pack's own changelog shows the fix: an update (version 0.30) reworked it to take an explicit loop count and build a real list, rather than relying on ComfyUI re-accepting a repeated value. If you're on a reasonably current install, you're getting the fixed version described below - but it's a good reminder that "general purpose, accepts anything" nodes in a fast-moving pack like this one are exactly the ones most likely to have been quietly reworked under the hood at some point.

How it works

You set nb_loops - how many times you want the loop to run - and optionally feed in an input of any type. If you don't connect anything to input, the node falls back to whatever you typed into default_text. It builds a list of length nb_loops from that value and outputs it, which is what triggers ComfyUI's native downstream re-execution: connect a list output to anything, and everything past it runs once per item.

Inputs and outputs

nb_loops is an INT from 0 to 1000 (default 1) - the number of iterations. default_text is a STRING fallback used only when nothing's wired into the optional input. The optional input accepts anything (* type) - text, an image, a model reference, whatever you want repeated nb_loops times. Output is a single *-type list.

Installing it

Bundled with the rest of Bjornulf_custom_nodes. ComfyUI Manager → search the pack title → install → restart, or manually: cd ComfyUI/custom_nodes && git clone https://github.com/justUmen/Bjornulf_custom_nodes, then restart. No node-specific dependency.

Common issues & troubleshooting

The author's own guidance, straight from the README: don't use this node if a more specific one will do. There's now a dedicated Loop node for integers, one for floats, one for images, one for text lines - each of those has type-appropriate controls (a range and step for numbers, for instance) that this generic version simply doesn't offer. Reach for this one specifically when you're looping something that doesn't fit any of the specialized nodes - a model reference, a LoRA, some other non-standard type - not as a default habit.

Because it accepts and outputs * (anything), ComfyUI won't catch a type mismatch for you the way it would with a typed connection. If you wire an image into input and then try to connect the output somewhere expecting text, you'll get a runtime error rather than a friendly red-wire warning at graph-build time - be deliberate about what you're actually looping. And if you do run into the "duplicate output" style failure this node historically had, that's a strong signal you're on an old, unpatched copy of the pack - update it before assuming your workflow logic is at fault.

CategoryBjornulf

Inputs (3)

NameTypeDefaultDescription
nb_loopsINT10–1000
default_textSTRINGDefault input
inputopt*

Outputs (1)

NameTypeDescription
output*