Nodes/ComfyUI-IF_AI_tools/IF Step Counter🔢
ComfyUI Node

IF Step Counter🔢

A stateful counter that ticks up every run — for batch and loop bookkeeping

By if-ai·Created 2 years ago·Updated 11 months ago· 701
IF Step Counter🔢
    • number
    • float
    • int
    • string
    number_type
    mode
    start0.00
    stop0.00
    step1.00
    reset_bool

    IF Step Counter is the pack's ticking metronome. Most ComfyUI nodes are stateless - same inputs, same outputs, every time. This one isn't: every time the graph runs, it advances an internal counter by one, and hands you the new value. It's a genuinely useful trick in a graph engine that has no native loop, because it gives you a monotonically increasing number you can feed into a batch size, an index, a seed, or any node that needs to know "which run is this."

    Where it shines: drive a seed that changes per generation, pass the counter into a node that picks the next item from a list, or just count how many times a workflow has executed in a session. The increment_to_stop and decrement_to_stop modes clamp at a target, which turns it into a cheap iteration limiter.

    How it works

    Each node instance keeps its own counter dictionary, keyed by the node's unique ID in the graph - so two Step Counters in the same workflow count independently, and a copied node starts a fresh count. Every execution, IS_CHANGED returns NaN to force a run, the counter is read from memory, adjusted by mode, and stored back. reset_bool (a NUMBER input, so wire in a 0/1 value) resets it to start when it's >= 1. It outputs the same value four ways - number, float, int, and string - so whatever type your downstream node expects, there's a port for it.

    The inputs that matter

    • mode - increment, decrement, increment_to_stop, or decrement_to_stop. Pick the direction.
    • start / stop / step - the bounds and the amount per tick.
    • number_type - integer or float; this decides how the number output is formatted.
    • reset_bool - wire this if you want a way to snap back to start.

    Outputs: number, float, int, string - same value, four types.

    Installation

    Pack standard:

    cd ComfyUI/custom_nodes
    git clone https://github.com/if-ai/ComfyUI-IF_AI_tools.git
    pip install -r requirements.txt
    

    Or "IF_AI_tools" via ComfyUI Manager and restart. Nothing else to install.

    Gotchas

    The catch with stateful nodes is state: the count lives in Python memory, so restarting ComfyUI resets it, and if you want deterministic restarts you'll be manually resetting anyway. Also, since it forces execution every run, it's not a node to leave dangling in a graph you execute for unrelated reasons. It's a niche, small utility in an archived pack - but for "change the seed every run" it's one of the cleanest options around.

    CategoryImpactFrames💥🎞️/IF_tools

    Inputs (6)

    NameTypeDefaultDescription
    number_typeCOMBO2 options: integer, float
    modeCOMBO4 options: increment, decrement, increment_to_stop, decrement_to_stop
    startFLOAT0.00-99999999999999–99999999999999
    stopFLOAT0.00-99999999999999–99999999999999
    stepFLOAT1.000–99999
    reset_booloptNUMBER

    Outputs (4)

    NameTypeDescription
    numberNUMBER
    floatFLOAT
    intINT
    stringSTRING