Nodes/qq-nodes-comfyui/Any List Iterator
ComfyUI Node

Any List Iterator

Walk a list one item at a time, no grid required

By kenjiqq·Created 3 years ago·Updated about a year ago· 76
Any List Iterator
  • list
  • AXIS_VALUE
counter0

Any List Iterator is the pack's "I just need the next value, not a whole grid" escape hatch. You give it a LIST and an integer counter, and it hands back one element from the list - the element at counter % len(list), to be precise. Bump the counter each run and the node walks the list for you, wrapping around to the start when it runs off the end.

It comes from kenjiqq/qq-nodes-comfyui, and it exists because the pack's XY Grid machinery is built on AXIS_VALUE - the polymorphic type that carries "whatever single value" out of a list. This node is that machinery exposed without the grid: you get the same per-run stepping, but you control the counter yourself instead of letting XY Grid Helper drive it.

Inputs and output

  • list - the LIST to step through (from Any List, Load Lines From Text File, Text Splitter, anything).
  • counter - an INT, default 0. The position. This is the input that does the work.
  • AXIS_VALUE - the output: one element of the list.

Because the output is AXIS_VALUE, you almost always follow it with an Axis To X converter to get a concrete type your target node accepts - Axis To STRING for a prompt, Axis To FLOAT for a CFG value, Axis To MODEL for a checkpoint. That's the same pattern the grid nodes use; here you're just doing the stepping by hand.

How to drive the counter

This is where beginners get stuck, because nothing in ComfyUI "auto-increments" per queue by default. The iterator is passive: feed it a fixed counter and you'll get the same list item every run, forever.

Practical sources for a changing counter:

  • A seed or batch-count node that changes each run.
  • The index-style counter of another loop/accumulator node (e.g. feeding it from a custom widget or a feedback node).
  • RememberLastSeed / ShowLastSeed style utilities - any workflow state that increments.

The modulo wrap (counter % len(list)) means you don't have to keep the counter within range - it'll happily cycle, which is handy if you want list stepping to loop forever without an error.

When you'd pick this over a grid

Honestly, XY Grid Helper is the main event of this pack and if you're already setting up a sweep, use the grid. The iterator is for the edge cases:

  • You want to vary one thing across a series of single images, not a full cross-product.
  • The value you're varying isn't an axis you want labeled in a grid.
  • You're building a "next prompt in sequence" queue and want the list to wrap.

It's a small node, but it's the one that makes the pack's list handling reusable outside grids.

Installing it

No dependencies beyond the pack itself:

cd ComfyUI/custom_nodes
git clone https://github.com/kenjiqq/qq-nodes-comfyui

Restart, or install qq-nodes-comfyui via ComfyUI Manager. You'll find it under QQNodes/List. One caveat worth repeating: it has no opinion about where the counter comes from - that part is on you.

CategoryQQNodes/List

Inputs (2)

NameTypeDefaultDescription
counterINT0
listLIST

Outputs (1)

NameTypeDescription
AXIS_VALUEAXIS_VALUE