TextTruncateTokens
Know exactly what CLIP is going to cut before it cuts it
- clip
- text_words
- text_clip_l
- text_clip_g
- text_t5
CLIP has a hard 77-token ceiling - that's true for the CLIP-L and CLIP-G encoders behind SD1.5, SDXL, and SD3.5's third encoder alike. Go past it and ComfyUI's normal CLIPTextEncode doesn't error, it just quietly stops counting the rest, or wraps it into a second chunk depending on setup, and you never quite know what got dropped. T5 (the encoder Flux and SD3.5 also lean on) tolerates far more. TextTruncateTokens exists so you can see and control the cut yourself instead of finding out the hard way that the second half of your prompt never mattered.
How it works
Feed it a source prompt and it returns several truncated copies, one per limit you care about - a plain word-count cut, and three token-based cuts matched to the specific encoders your workflow might be using. Plug the copy that matches whichever encoder you're actually feeding into CLIPTextEncode downstream.
The inputs and outputs that matter
text(STRING) - your source prompt.truncate_words_to(default 30) - a plain word-count truncation, independent of any encoder.truncate_clip_l_to/truncate_clip_g_to(default 77 each) - token-based truncation matched to CLIP-L and CLIP-G's actual 77-token limit. Raising these past 77 won't get you more usable prompt room - the encoder itself won't use the extra tokens.truncate_t5_to(default 77) - truncation for the T5 encoder used by Flux and SD3.5's third slot; T5 doesn't share CLIP's hard 77 ceiling, so raise this one if you actually want more room and your workflow's T5 stage supports it.clip(CLIP, optional) - plug your actual loaded CLIP model in here and the node tokenizes for real instead of estimating from word splits, giving you accurate counts rather than an approximation.- Outputs:
text_words,text_clip_l,text_clip_g,text_t5- four differently-truncated versions of your prompt.
How to install it
Via ComfyUI Manager: search RES4LYF, install, restart.
Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF
cd RES4LYF
pip install -r requirements.txt
Portable installs: use the embedded Python's pip.exe. No model downloads for this node - the optional clip input just points at whatever CLIP model you've already loaded elsewhere in the workflow.
Common issues & troubleshooting
Skipping the clip input. Without it, the token-based fields fall back to a rougher word-based estimate rather than real tokenization, which can be noticeably off from what your encoder will actually count - plug your CLIP model in if you want the truncation to be accurate rather than approximate.
Expecting more prompt room by raising truncate_clip_l_to or truncate_clip_g_to past 77. The 77-token cap is a property of the encoder itself, not this node's setting. Raising the field doesn't change what CLIP will actually attend to.
Prompt still getting cut somewhere you didn't expect. Make sure you're wiring the matching output into the matching encoder - feeding text_clip_l into a T5 encode step (or vice versa) truncates against the wrong limit and won't reflect what actually happens downstream.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| truncate_words_to | INT | 300–10000 | — |
| truncate_clip_l_to | INT | 770–10000 | — |
| truncate_clip_g_to | INT | 770–10000 | — |
| truncate_t5_to | INT | 770–10000 | — |
| clipopt | CLIP | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| text_words | STRING | — |
| text_clip_l | STRING | — |
| text_clip_g | STRING | — |
| text_t5 | STRING | — |