IF Step Counter🔢
A stateful counter that ticks up every run — for batch and loop bookkeeping
- number
- float
- int
- string
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, ordecrement_to_stop. Pick the direction.start/stop/step- the bounds and the amount per tick.number_type-integerorfloat; this decides how thenumberoutput is formatted.reset_bool- wire this if you want a way to snap back tostart.
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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| number_type | COMBO | 2 options: integer, float | |
| mode | COMBO | 4 options: increment, decrement, increment_to_stop, decrement_to_stop | |
| start | FLOAT | 0.00-99999999999999–99999999999999 | — |
| stop | FLOAT | 0.00-99999999999999–99999999999999 | — |
| step | FLOAT | 1.000–99999 | — |
| reset_boolopt | NUMBER | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| number | NUMBER | — |
| float | FLOAT | — |
| int | INT | — |
| string | STRING | — |