计数器
The Counter That Survives Re-Runs (File Names, Loops, Done Right)
- STRING
- float
- int
ComfyUI has no native "number that ticks up each time I run this" - and that's a real hole. People fake it with seeds, renumber files by hand, or bolt on Python hacks. hb_Number_Counter (display name "计数器") from the 1H-hobit/ComfyUI_InternVL3 pack is the simple version: a counter that increments every time the graph runs and remembers its value between runs, so you can label saved images 001, 002, 003 without ever touching the filename widget again.
How it works
Each copy of the node keeps its own state, keyed by its node id, held in memory. Because the node declares IS_CHANGED as always-changed, it executes on every queue run - that's what makes it a counter and not a "sets itself once and freezes" node. Restart ComfyUI and it resets to start; copy the node and the copy starts fresh. Nothing persists to disk, which is usually what you want for batch naming.
Pick a behavior with mode:
increment/decrement- tick up or down bystepforever.increment_to_restart- count up untilstop, then snap back tostart. Same idea backwards withdecrement_to_restart. This is your loop counter for workflows that should run a bounded number of passes before recycling.
The inputs that matter
number_type-integerorfloat. Controls how the value is formatted on the outputs.start,stop,step- all floats.stepdefaults to 1; there's no reason to set it below 0.reset_bool- optional numeric input. Feed it a value ≥ 1 and the counter snaps back tostart. Wire a boolean toggle or a threshold check in here for "restart the count now" control from inside the graph.
Outputs
The same value, three ways, so you can grab whichever type a downstream node wants: STRING, float, and int. The detail that makes it worth reaching for: in integer mode the string is zero-padded to three digits - 001, 002, 042. That's exactly what you want when building a filename so image viewers sort them correctly. Feed the STRING output into a save-image node's filename template and batch output numbering just works.
Install
It ships inside the InternVL3 pack, which is mostly about running InternVL vision-language models - but this node has nothing to do with any of that. Manager → search ComfyUI_InternVL3, or:
cd ComfyUI/custom_nodes
git clone https://github.com/1H-hobit/ComfyUI_InternVL3.git
Restart ComfyUI. The repo has no requirements.txt, so nothing installs automatically, and this node needs nothing beyond core ComfyUI anyway - no model download, no HuggingFace account, no GPU strain. You can use it even if you never load a single InternVL model.
Where people get tripped up
The obvious one: the counter bumps on every graph execution, not once per image in a batch. If your workflow batches 4 images, a single run ticks the counter 4 times, so 001 becomes 004 before you've even looked at the first output. If you need one tick per run regardless of batch size, put it after a node that executes once, or accept the behavior and plan for it. Also keep the memory-only state in mind: it's not a "set this to 7" constant - it's genuinely a running tally, and a workflow that re-executes for unrelated reasons (you tweaked a prompt and reran) keeps counting. For filename sequencing it's the right tool; for anything that needs deterministic state, it isn't.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| number_type | COMBO | 2 options: integer, float | |
| mode | COMBO | 4 options: increment, decrement, increment_to_restart, decrement_to_restart | |
| start | FLOAT | 0.00-18446744073709550000–18446744073709550000 | — |
| stop | FLOAT | 0.00-18446744073709550000–18446744073709550000 | — |
| step | FLOAT | 1.000–99999 | — |
| reset_boolopt | NUMBER | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |
| float | FLOAT | — |
| int | INT | — |