字符串计数/文本框
A character counter for your prompts — just don't mistake it for a token counter
- text
- length
This one does exactly one thing: count the length of a string. Type or wire in some text, get back the number. It's from the same utility shelf as the rest of ComfyUI-My-Nodes, and it's the kind of node you don't think about until you're suddenly counting characters by hand.
The mechanism is about as deep as it gets - the source calls Python's len() on whatever text is in the box. Spaces and newlines count, so a multiline prompt includes its line breaks in the total. Input is text (STRING, multiline, so you can type straight into the widget instead of wiring in a CLIPTextEncode). Outputs are text - the same string, passed through untouched so you can keep the chain alive - and length (INT).
The trap that gets people: this counts characters, not tokens. CLIP's famous 77-token limit is a token limit - roughly sixty English words - and a 500-character prompt is nowhere near that wall. So if your actual problem is "my prompt is too long for the text encoder," this node will not save you; you want a real token counter for that. Where it is the right tool: character-limited API calls (plenty of hosted text and image endpoints cap payloads by character count, and this pack lives in that DashScope world), filename or metadata field limits, or sanity-checking that a caption stays under some arbitrary N before you write it out.
It's also a perfectly good pass-through text box in a tight graph. Wire your prompt in, route the text output onward, and read length while you're at it. Two birds, one node, no model download, no API key.
Install is shared with the rest of the pack - ComfyUI Manager and search "ComfyUI-My-Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Tagbliton/ComfyUI-My-Nodes
then restart. The pack's install pulls dashscope, openai, requests, soundfile, numpy, and a pinned urllib3==1.26.20 for its AI nodes; this one needs none of it. If installing the pack breaks ComfyUI startup, that urllib3 pin is the first thing to check (the author calls it out explicitly as a version that must stay at 1.26.20).
There's no real failure mode beyond expecting tokens. It's a character count, spaces and newlines included - read it that way and it just works.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| length | INT | — |