Prompt Token Counter π’
Know your prompt is about to get truncated before you waste a generation
- token_count
- will_truncate
- truncated_preview
- summary
The silent killer of long prompts is truncation. CLIP encoders on the SD1.5/SDXL lineage cap your text at 77 tokens (75 usable plus the special tokens), and everything past that boundary is silently dropped - you've been writing prompts that get chopped mid-sentence and wondering why the tail never shows up in the image. Prompt Token Counter π’ counts your prompt's tokens and tells you, before you spend GPU time, whether it's going to be truncated.
It's a diagnostic node with a bit of meat on it: it uses the real transformers CLIP tokenizer when available (exact count) and falls back to a whitespace/punctuation heuristic when not (roughly right for typical English, enough to flag truncation risk).
How it works
Token counting on CLIP is a BPE wordpiece operation, which is why a naive character count lies to you. This node hands the prompt to CLIPTokenizer if transformers is installed - and it usually is, since ComfyUI bundles it - and strips the BOS/EOS the tokenizer adds, giving you the usable token count. Then it compares against a budget of 75 tokens per chunk, multiplied by chunk_size.
The chunk_size input matters more than beginners expect: ComfyUI's default CLIP Text Encode concatenates multiple 75-token chunks automatically, so a chunk_size of 2 means a 150-token budget. Set it to match the encoder your workflow actually uses, or you'll get false "will truncate" alarms on legitimately long prompts.
The inputs and outputs
Inputs: prompt and chunk_size (1β10, default 1). Outputs: token_count (INT), will_truncate (BOOLEAN), truncated_preview (STRING - the prompt as it would survive truncation), and summary. truncated_preview is the genuinely useful one: it shows you the exact cut point, so you can see what's dying and fix the prompt instead of guessing.
Wire will_truncate into a conditional gate if you want a workflow that refuses to queue over-budget prompts - the honest version of a token guard.
Installing it
Part of OmniNodes:
cd ComfyUI/custom_nodes/
git clone https://github.com/TensorVizion/OmniNodes
Restart ComfyUI (or search "OmniNodes" in ComfyUI Manager). No extra pip installs - it uses transformers if ComfyUI already has it and degrades gracefully otherwise. Registers under TensorVizion/Prompt. If it doesn't appear, restart completely and check the terminal for [OmniNodes] β
Loaded lines.
Two honest caveats. First, this is about CLIP-style encoders - the LLM-encoded 2026 models have no 77-token boundary at all, and this node's budget math doesn't apply to them. Second, an exact count still depends on the tokenizer being available; the heuristic fallback is close but not exact. For the SDXL-lineage world where truncation is a real daily problem, it's exactly what you want between the prompt builder and the encoder.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | β | |
| chunk_size | INT | 11β10 | β |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| token_count | INT | β |
| will_truncate | BOOLEAN | β |
| truncated_preview | STRING | β |
| summary | STRING | β |