Simple Counter
The one-node trick for stepping through a batch in order
- index
Simple Counter is the smallest possible answer to a surprisingly common ComfyUI problem: you have a batch of N items and you need each one to know its own number. Queue a prompt with a batch count of 30 and this node hands back the integers 0, 1, 2, … 29, one per item, then starts over the next time you hit Queue Prompt. That's the whole job, and it does it without a single Python dependency.
You reach for it when your workflow is doing something sequential. The pairing the author built it for is Load Image Batch from WAS Node Suite plus a batch count: feed it a folder of images, run the queue once, and each generated image gets its own index to stay coordinated with. Same pattern works for stepping through a list of prompts, checkpoint variants, or seeds. Without something like this, "iterate over these images in order" turns into the kind of wrestling match people post r/comfyui help threads about - Load Image Batch exists, but controlling exactly which item you're on mid-batch is where the fight lives. This is a clean integer you can wire into anything that wants to know the Nth item.
How it actually counts
The Python half of this pack is a stub. SimpleCounter.py only defines the node - start and count in, index out, and run() just returns the count it was handed. Every bit of counting happens in a JavaScript extension, and the author says so in the README: there's no way for a node to know when a batch starts, so the frontend handles it.
Here's the trick: the extension hides the count widget and overrides its serializeValue to return counter++ every time the graph is serialized. When you queue with a batch count of N, ComfyUI's frontend serializes the graph once per batch item - that's per item, not per press - so count walks up by one for each queued run. A promptQueued event listener resets the counter to start when you press Queue Prompt again. The node also sets IS_CHANGED to NaN, which is a ComfyUI idiom for "never cache me, always re-run" - necessary for a counter that's supposed to move.
The one real consequence: the number is decided at queue time, in the browser, not when the node executes.
Inputs and outputs
Only two fields exist, and you really only touch one of them:
- start (INT, default 0, min 0) - where the count begins. Set this to 1 if your filenames are 1-based and you don't want to add 1 downstream.
- count (INT) - technically required, but the extension hides it in the UI and feeds it itself. Ignore it; the schema has to list it because the Python node needs an input, but you'll never set it.
- index (INT output) - the current batch number. Wire this into your image loader, prompt chooser, seed, or whatever needs the Nth item.
Installing it
ComfyUI Manager finds it by searching "ComfyUI-SimpleCounter" (the author publishes it to the Comfy Registry). Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/AonekoSS/ComfyUI-SimpleCounter
Restart ComfyUI, then look under the utils category. There's no requirements.txt, nothing to pip install - it's pure JS on top of a definition-only Python class. About the lightest install you'll ever do in this ecosystem.
Where people trip
The reset is by design, and it surprises people. This is a per-run counter: every Queue Prompt starts fresh from start, so it can't pick up where a previous batch left off. If you want a persistent counter that survives re-queues and browser reloads, this isn't the node. And because the value bakes in when you queue, editing start after queuing doesn't renumber anything already sitting in the queue - interrupt first if you need to change course. One more quirk: the counter advances at serialization, so if a node later in the graph fails partway through a batch, the count has already marched past the failed items. For the common case - a clean batch through an image folder - none of this bites.
It's a two-input node that outputs one integer and lives or dies by the frontend. In a workflow that needs ordered batch steps, that's all it needs to be.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| start | INT | 0 | — |
| count | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| index | INT | — |