Count
The iteration counter that feeds Loop
- _node
- _count_int
- _count_event
Count is the pack's "how many times has this run?" node, and its whole reason for existing is to feed the Loop node. Loop needs a tripwire: keep re-executing while true, stop when false. Count is how you count to "20 and no more."
The pattern is simple. Wire whatever node you're looping into Count's _node input (it accepts anything - it just needs something to hang the execution trigger on), so Count runs once per loop iteration. Each time it runs, it increments its counter and emits two outputs: the raw count as an INT, and an event object that Loop understands. You connect that event to Loop's _event input, set the threshold, and the loop stops when you've had enough iterations. That's the whole loop control stack this pack offers: Loop + Count + two Holds.
How it works
Count keeps a per-node counter in a module-level database keyed by node id and prompt run, so the count resets for each new queue instead of accumulating across runs. The _event widget (default "10") is the threshold: the event output carries a boolean of whether the current count has reached it. The source has a commented-out TODO describing a richer _event syntax - ranges like (0, 9], step values like [0, 9, 2], comma lists of specific numbers - but that's a plan, not a shipped feature. What actually works today is the plain threshold: the event fires when the count passes the number you typed.
The inputs and outputs
_node- anything from the looped part of your graph. The connection, not the value, is what matters._event- the threshold string, default"10"._count_int- the current count, as anINT(0 on the first execution)._count_event- anEVENT_TYPEcarrying{id, bool}; wire this intoLoop's_event.
How to install it
The usual:
cd ComfyUI/custom_nodes
git clone https://github.com/Trung0246/ComfyUI-0246
restart, or ComfyUI Manager → search "ComfyUI-0246". No models.
Common issues & troubleshooting
The count doesn't advance. Count only increments when the node executes, and inside a Loop that means it has to sit inside the re-executed slice. If it's outside the looped region, it runs once and stays at 1.
The count carries over between queues. It shouldn't - the database is keyed to the prompt run - but if you're using a fresh queue without the Loop actually re-running, stale state can look persistent. Restart the queue (or add a clear-mode Hold pattern) to reset.
The loop never stops. Your _event threshold is higher than the number of iterations you're actually driving, or _event's value isn't being read the way you think. Set it to the count you want, and remember the first execution reports 0.
And one honest note: Count is a tiny node - a counter with two outputs. The interesting, fragile part of this stack is Loop, so if Loop breaks on a ComfyUI update, Count becomes a very pretty useless counter until the pack (dormant since early 2025) catches up.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| _node | * | — | |
| _event | STRING | 10 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| _count_int | INT | — |
| _count_event | EVENT_TYPE | — |