Nodes/ComfyUI-Counternodes/Interval Counter
ComfyUI Node

Interval Counter

A counter that only ticks every N runs — perfect for stepping seeds, prompts, and CFG on a schedule

By GHOSTLXH·Created 2 years ago·Updated 2 years ago· 11
Interval Counter
    • INT
    resetfalse
    modeincrement
    min_value0
    max_value100
    step1
    trigger_interval3
    tick0

    This is the node the whole pack is named after, and it solves a surprisingly annoying problem: you want something to change every N renders, not every render. A plain counter bumps on every execution, so to vary your seed every third image you'd have to babysit the workflow. Interval Counter lets you set a trigger_interval of 3 and it simply won't move until three rounds have gone by. Set it to 1 and it behaves like any other counter; set it to 10 and it's basically a slow heartbeat for your batch.

    How it works

    Internally it keeps two numbers: the output value and an interval counter. Every time the node executes, it bumps the interval counter. When that hits trigger_interval, it resets the interval and applies whatever mode you picked:

    • increment - value += step
    • decrement - value -= step
    • inc_to_max - jump straight to max_value
    • dec_to_min - jump straight to min_value

    One thing the README gets wrong: it claims min/max only matter in the jump modes, but the code clamps in increment and decrement too. So increment with max_value 100 stalls at 100 rather than running past it. Plan accordingly.

    There's a reset boolean that zeroes the value (well, back to min_value) and restarts the interval count. Wire it to a boolean toggle and you can restart a run series without reloading the workflow.

    The inputs that matter

    You'll actually touch three of them: trigger_interval, step, and mode. The tick input is the weird one. Because ComfyUI caches nodes whose inputs never change, a counter fed only constants executes once and then returns the same cached value forever. The author's fix: feed a value that changes every run into tick - the README suggests a counter node from WAS Node Suite - so the node's hash stays dirty and ComfyUI re-executes it. The tick value isn't used in the math at all; it's purely a "please keep running me" wire. The community has used WAS counters for exactly this for years (thread 16g0g76 is the classic "better incrementer" ask), so this is a known, real pattern.

    The output is a single INT. Wire it into anything that takes a number - seed, CFG, a prompt index, a strength.

    Installing it

    It ships in the ComfyUI-Counternodes pack, so ComfyUI Manager handles it: search ComfyUI-Counternodes and install, then restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GHOSTLXH/ComfyUI-Counternodes
    

    No model downloads, no extra Python packages - it's plain Python plus torch, which ComfyUI already has.

    Where people get burned

    Three traps, all real. First, the caching one above: if your counter seems frozen at 0, you forgot tick. Second, the state is persisted to interval_counter_state.json inside the pack folder, so the count survives ComfyUI restarts - and worse, it's shared between every workflow that uses the node. A fresh project can start mid-count. Hit reset once (or wire it true) or delete that JSON file to start clean. Third, if you've used this node in multiple workflows, they're all reading and writing the same state file, so they fight each other. It's a niche tool with a niche quirk - but for scheduled variation across a run series, nothing in core ComfyUI does it this directly.

    CategoryCustom Nodes/Counters

    Inputs (7)

    NameTypeDefaultDescription
    resetBOOLEANfalse
    modeCOMBOincrement4 options: increment, decrement, inc_to_max, dec_to_min
    min_valueINT00–10000
    max_valueINT1000–10000
    stepINT11–10000
    trigger_intervalINT31–10000
    tickINT00–999999

    Outputs (1)

    NameTypeDescription
    INTINT