Truncate Text
The 77 that still haunts CLIP
- texts
Truncate Text cuts a string down to a maximum length. Nothing fancier than that: you give it text, it keeps the first N characters and drops the rest. It's the rare member of this little family that isn't deprecated - no sticker, still current.
The interesting part is the default. max_length defaults to 77, and that number is a fossil. SD 1.5 and SDXL's CLIP text encoder had a hard 77-token context window, and every tool from that era spent its life chunking prompts at 77. This node's default is a nod to that history - which is convenient, because it's also the source of its most common misuse.
How it works
One line of Python under the hood: text[:max_length]. Pure character slicing - no tokenizer, no word-boundary awareness, no ellipsis appended. It doesn't know what a word is, so it will happily cut "delicate" down to "delic" if that's where the boundary lands.
The inputs you'll actually touch:
texts- the string to shorten.max_length- an integer from 1 to 10000, default 77. The tooltip says it plainly: "Maximum text length."
Output is a single STRING with the truncated text.
Where it's genuinely useful
- Filenames. A long auto-generated title (or a long prompt used as a filename prefix) gets chopped to something filesystems and tools won't choke on.
- Capping runaway text. If some upstream node produces a 40,000-character monster and you only need the first bit for a label or a comparison, truncate it before it goes anywhere important.
- Dataset prep. Rows with fixed-width expectations - a job this family of nodes was built around.
Where people get burned
- 77 characters ≠ 77 tokens. This is the big one. A CLIP token averages roughly 2–3 characters and frequently spans a whole word, so slicing at 77 characters cuts mid-word and throws away meaning that a real 77-token cut wouldn't. If you're trying to enforce the old SD1.5/SDXL token budget, this node isn't the tool - you'd need an actual tokenizer.
- Modern models have no 77 boundary. The text encoders that took over in the LLM-encoded generation (Qwen-based and T5-style encoders) take thousands of tokens and never truncate at 77. Hard-capping your prompt at 77 characters on those just deletes information for no reason. The 77 default is a legacy, not a law.
- Mid-word cuts. Because it slices by character, you can end up with a dangling "delic" in a prompt. If you're truncating a prompt meant for a human or an LLM encoder, a word-aware cut (or just not truncating) serves you better.
It's part of the same dataset text-processing family as the now-deprecated Strip Whitespace and the case converters, and it ships with ComfyUI core - no install, no Manager, nothing to load.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| texts | STRING | Text to process. | |
| max_length | INT | 771–10000 | Maximum text length. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| texts | STRING | Processed texts |