CLIPTokenCounter
How many tokens is your prompt, really
- clip
- count
- count_advanced
- parsed_tokens
Simple, honest utility: paste a prompt, get the token count back. CLIPTokenCounter tells you exactly how many tokens your text turns into once CLIP tokenizes it - which is almost never the number of words you typed, and knowing the difference saves you from a subtle prompt bug.
Why token count matters
CLIP - the encoder behind SD1.5, SDXL, Illustrious, NoobAI, Pony - reads prompts in blocks of 77 tokens (75 usable, plus start/end markers). And tokens aren't words: "photorealistic" might be two or three tokens, an emoji or a weird bit of punctuation can be several, and a comma is its own token. So a prompt that looks like 60 words can quietly be 90+ tokens, which means it spills past the 77-token boundary into a second chunk. When that happens, whatever got pushed over the line lands in a fresh attention chunk and stops interacting with the concepts before it - sometimes that's fine, sometimes it's why the last third of your prompt seems to get ignored.
Counting tokens turns "why is the model dropping my last few tags" from a guess into a fact. You see the number, you see where the chunk boundary falls, and you decide whether to trim, reorder, or deliberately BREAK.
Inputs and outputs
- clip (CLIP) in - it counts using your model's tokenizer, so the number is accurate for the model you'll actually run.
- text (STRING, multiline) - the prompt to measure.
Three string outputs:
- count - the headline number.
- count_advanced - a more detailed breakdown (useful when you want to see how it splits across chunks).
- parsed_tokens - the actual tokens your text became, so you can see exactly where a word got chopped into pieces.
This is an output node, so it'll display in the UI when you run it, but the clean way to read the strings is to wire an output into a Preview Any node - the README suggests exactly that. Then the counts show up as text you can actually read.
Install
No models, no deps:
- ComfyUI Manager: search "ComfyUI-ppm", install, restart.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/pamparamm/ComfyUI-ppm, then restart.
When it's useful - and when it's pointless
Genuinely handy on CLIP models when you write long, tag-heavy prompts and want to keep things under (or deliberately across) the 77-token line. Because it uses your model's own CLIP, the count reflects reality rather than some generic estimate.
The catch: this is a CLIP thing. On modern LLM-encoded models - Z-Image, Flux, Anima, Krea, ERNIE - the 77-token limit is gone; those encoders swallow thousands of tokens, so "how close am I to 77" is a non-question. That said, the counter still isn't useless there, because attention is still finite even without a hard cap - people who've run hundreds of Z-Image generations report the model starts to drift past roughly 75-100 effective tokens, so a long prompt actively hurts. Seeing your real token count is a decent reminder to cut a 400-word prompt down to a few strong concepts. Just don't treat 77 as a wall on those models - it isn't.
Pack rule: if it errors after an update, delete and re-add it. Otherwise this is a read-only utility that can't hurt anything - measure away.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| text | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| count | STRING | — |
| count_advanced | STRING | — |
| parsed_tokens | STRING | — |