Tag Counter
Count how many tags are actually in your prompt
- tag_count
Once you're generating prompts with wildcards, brackets, and repack nodes instead of typing them by hand, you stop knowing exactly what you're feeding the sampler. Tag Counter is the small sanity-check node for that: plug in a string, get back an integer telling you how many tags - comma-separated phrases - are actually in it. It's a debugging tool more than a creative one, and it earns its keep precisely because it's boring.
One thing worth flagging up front: the pack's own README table currently describes Tag Counter with a line that's clearly copy-pasted from String Split ("directly splits a prompt into 3 parts...") - that's a documentation slip on the author's part, not what the node does. Go by the node's actual inputs and outputs instead, which is what this article does.
How it works
The Adaptive Prompts README defines a "phrase" as the space between two commas - in masterpiece, this is a phrase, low quality, the middle chunk is one phrase. Tag Counter takes that same unit and counts it: feed it a string, it splits on commas and reports how many segments came out the other end. There's no filtering, no dedup, no attempt to understand whether a segment is a real Danbooru-style tag versus a sentence fragment - it just counts comma-delimited pieces, which is exactly what you want from a quick gut-check node.
The inputs and outputs that matter
string- the only input. Whatever prompt text you want measured, typically the output of a Prompt Generator, Prompt Repack, or a chain of the pack's other processing nodes.- Output:
tag_count, anINT. Wire it into a Show Text-style debug node (or anything that displays a number) to watch it live as you tweak upstream nodes.
That's genuinely the entire node - one string in, one number out.
How to install it
Ships with the rest of the pack, no separate steps. Via ComfyUI Manager, search comfyui-adaptiveprompts and install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Alectriciti/comfyui-adaptiveprompts
Restart ComfyUI. No models, no extra Python dependencies - it's a pure string operation, so there's nothing here that can fail beyond a missed restart.
Common issues & troubleshooting
The count doesn't match what you expected after a Prompt Generator run. This is usually not a bug in Tag Counter - it's dynamic prompts doing what dynamic prompts do. A {2-4$$__animal__|__color__} bracket can resolve to anywhere from two to four comma-separated results in a single generation, so your tag count is supposed to move around run to run. If you want a stable count, fix the seed and check whether the variance is coming from a range-selection bracket upstream.
A weighted phrase inflates the count. Since the node is almost certainly doing a plain comma split, a phrase like (cat, sitting:1.2) that has an internal comma inside parentheses will likely read as two tags instead of one, because the split doesn't know about parentheses. If your counts look consistently higher than a manual count of your prompt, check for commas hiding inside weighted groups or Prompt Repack output before assuming something else is wrong.
Using it as a proxy for token budget. Tag count isn't the same as token count, but it's a decent early-warning signal. On models with a real attention cap - the community's own measured finding is that quality starts drifting past roughly 75–100 effective tokens even on modern LLM-encoded checkpoints - a prompt that's ballooned to 40+ tags from nested wildcards is worth trimming regardless of what your token counter says later in the graph. Tag Counter is the cheap, upstream check before you get to a real tokenizer node.
Empty string in isn't necessarily zero out. A lot of split-on-comma implementations return one empty segment for an empty string rather than zero, so don't be surprised if tag_count reads 1 when your upstream node silently produced nothing. Use it as a "did anything even come through" check rather than assuming 0 means empty - trace back to whatever fed the string input if the count looks off in either direction.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| tag_count | INT | — |