ComfyUI Node

Index Iterator

The tiny counter that runs your style sweeps

By andreszs·Created 6 months ago·Updated 13 days ago· 8
Index Iterator
    • index
    resetfalse
    start0

    Index Iterator is the pack's quiet workhorse: a single INT output that increments by one every time the workflow runs. On its own it does nothing interesting. Hook it into Styler Pipeline (By Index) and it becomes the engine for unattended style sweeps - queue the workflow, and each render applies the next style in the category without you touching the graph. It's about as simple a node as this pack ships, so there's not much to it, but there are two details worth knowing before you wire it up.

    What it does

    Give it a start value (default 0) and a reset boolean (default false). On its first run - or whenever reset is switched to true - it returns start. Every run after that, it returns the previous value plus one. That's the entire mechanism: the counter lives in memory, keyed to that specific node instance, and the node always re-executes so the number actually changes instead of ComfyUI caching the result.

    The reset toggle is the control surface you'll actually touch. Turn it on, run once, turn it back off - you've rewound the sweep to start without restarting anything. And because the state is in-memory, restarting ComfyUI zeroes every iterator anyway, so there's no stale counter to trip you up on a fresh session.

    The two gotchas

    Each copy of the node has its own counter. The state is tracked per node ID, not globally. That's usually what you want - two iterators in different parts of a graph shouldn't fight over one number - but it means duplicating the node to "share" a counter won't work. Wire the same index output wherever you need the same value.

    It counts runs, not renders. The counter bumps each time the node executes in a queued workflow. That's perfect for the README's recommended pattern - Index Iterator's index into Styler Pipeline (By Index)'s style_index, one style per queue. Just don't expect it to advance mid-batch within a single run; that's a different kind of loop and this isn't it.

    Installing it

    It's one of five nodes in andreszs' ComfyUI-Styler-Pipeline - no separate install, no dependencies, no model files.

    cd ComfyUI/custom_nodes
    git clone https://github.com/andreszs/ComfyUI-Styler-Pipeline
    

    Restart ComfyUI and it shows up under Styler Pipeline/Helpers (ComfyUI Manager also works, search "Styler Pipeline"). Then it's a two-node circuit: iterator's index → styler's style_index. Remember the pack's standing caveat - the applied style won't be recoverable from the saved workflow afterward, so make sure the By Index node's style output ends up in your filename or your sweep results will blur together.

    CategoryStyler Pipeline/Helpers

    Inputs (2)

    NameTypeDefaultDescription
    resetBOOLEANfalse
    startINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    indexINT