Text Length
How long is this prompt, really? Characters, words, lines, bytes
- text
- char_count
TextLength answers a question that sounds trivial until it bites you: how long is this string? One input (text), an output dropdown with five choices, and two outputs - a STRING and an INT. It's the least glamorous node in the wwdm-aicd pack, and it's exactly the kind of plumbing that saves you from a dumb failure at the wrong moment.
The output mode picks what the STRING says. summary gives you the full line - character count, word count, line count, byte size in one string. The other four (char_count, word_count, line_count, byte_size) give you just that one number as a string. The second output, the INT socket named char_count, is always the raw character count regardless of mode. So yes, there's a mild quirk: set output to byte_size and the STRING says "17" while the INT output still says 15 characters. Don't wire the INT into something expecting the byte count, because you'll get characters.
The counts themselves are plain Python: characters is len(text) - which counts every character including spaces and newlines - words is split-on-whitespace, lines is split-on-newline, and bytes is the UTF-8 encoded size. The byte count is the one that surprises people, because it's only equal to the character count for ASCII. "Hello World 你好" is 15 characters but 17 bytes, since each Chinese character costs 3 bytes in UTF-8. If you're budgeting for a model's token limit or a field size on an API, bytes is often the number that actually matters, and the node's README example deliberately shows that mixed-script case.
Real uses: checking a generated prompt before it hits an encoder, validating that an LLM's output isn't empty or absurdly long, or logging stats. The INT output is genuinely useful for conditional logic - TextJudge can compare lengths, but if all you need is "did this come back non-trivial," you can chain TextLength's INT into anything that takes a number.
Install is the pack standard, which is refreshingly light:
cd ComfyUI/custom_nodes
git clone https://github.com/wwsmiao/comfyui-wwdm-aicd.git
Restart ComfyUI and it's under the wwdm-aicd category. No models, no GPU, no network - just stdlib. The README's pip install -r requirements.txt line is a no-op because the repo ships no requirements.txt. README and comments are in Chinese; the widget labels are English.
Honest assessment: you won't build a workflow around this node, and you probably won't use it in every graph. But it's a one-node sanity check that's faster than eyeballing, and when you're debugging "why did the prompt get truncated," having char vs byte counts side by side tells you instantly whether you're fighting character limits or encoding limits. That alone is worth the two seconds it takes to drop in.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| outputopt | COMBO | summary | 5 options: summary, char_count, word_count, line_count, byte_size |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| char_count | INT | — |