SF Text Analyzer
Word count, a token estimate, and a summary string — the LLM cost sanity check
- word_count
- token_estimate
- summary
The pack's other nodes are all about sending text to an LLM or a paid image API. SF Text Analyzer is the piece of paper you hold up in front of the meter. Feed it any string and it tells you three things: the actual word count, an estimated token count, and a formatted one-line summary you can route into a display node. When you're about to shove a prompt through a pay-per-token LLM chat node, knowing roughly how many tokens you're spending before you hit send is the difference between "hmm" and a surprise invoice.
How it works
Honestly, this is a counting node with a number on the front. It splits your text on whitespace and counts words, then estimates tokens as character_count // 4 - the classic "one token per four characters" rule of thumb. The author is upfront in the tooltip and the code: this is an approximation, not exact Claude tokenization. If you want a precise number, you need a real tokenizer (which would mean pulling in a model file, which this pack deliberately doesn't do). For sanity checking, the 4-char rule is close enough that you'll never be off by an order of magnitude.
The inputs and outputs
- text - a multiline string input. Paste a prompt, a workflow variable, a caption - anything.
Three outputs:
- word_count (
INT) - the actual count. - token_estimate (
INT) - the char/4 estimate. - summary (
STRING) - a ready-to-display line likeWords: 120 | Tokens: ~480 (estimated). Handy for wiring into a "show text" node so the number is visible in your graph without any formatting work.
Installing it
It's in the SF ComfyUI Nodes pack from Stillfront. ComfyUI Manager → "SF ComfyUI Nodes" → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Stillfront/comfyui-sf-nodes.git
cd comfyui-sf-nodes
pip install -r requirements.txt
Zero dependencies beyond Python itself - this node imports nothing but the standard library.
Common issues
There isn't much to break. The one thing to keep in your head is the disclaimer: token estimates drift for non-English text and for code, where token-per-character ratios can be wildly different from prose. And since the summary output is a string, it won't display anywhere unless you wire it to a text display node - don't expect it to pop up on its own. If you want the numbers in a workflow decision (like "skip the LLM call if tokens exceed X"), wire the word_count or token_estimate INT outputs into a comparison node and let the graph decide.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Text to analyze |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| word_count | INT | — |
| token_estimate | INT | — |
| summary | STRING | — |