Nodes/was-node-suite-comfyui/Text String Truncate
ComfyUI Node Runs on cloud

Text String Truncate

Chop a string down to size, from either end

By WASasquatch·Created 3 years ago·Updated about a year ago· 1,812
Text String Truncate

      Exactly what it says: it truncates a string, from the beginning or the end, by characters or by words. Nothing fancier than that, and that's the appeal - half the time you don't need clever text processing, you need to make sure a string doesn't blow past a length limit somewhere downstream.

      Where it actually earns its slot

      The obvious use is filenames. If you're building a save filename out of a truncated prompt or a caption, most filesystems (and your own sanity when browsing an output folder) start to hurt somewhere past a couple hundred characters. Feed your full prompt or a BLIP-generated caption through this node, cap it at a sane length, and hand the result to WAS's Save Text File or Save Image filename pattern instead of the raw string.

      The other case is anywhere a downstream node or model has an effective input limit - a CLIP text encoder's token budget, a caption overlay that only has room for one line, a title field in some other tool your workflow feeds into. Rather than manually keeping your prompt short, you write it long and let this node cut it down automatically before it reaches the limit.

      How it works

      You give it a string, and it cuts from either the front or the back, counting either in characters or in whole words. Character truncation is the blunt option - fast and predictable, but it can land you mid-word. Word truncation costs a little more precision over the exact length but keeps what's left readable, which matters if the truncated text is going to be displayed rather than just used as an internal identifier. The output is a single truncated string, and it slots in anywhere a text input goes - another Text Concatenate, a Save node, a second Truncate node if you need to cut from both ends.

      Installing it

      This is one node out of the whole WAS Node Suite pack - you don't install it separately:

      • ComfyUI Manager - search WAS Node Suite, install, restart.
      • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/WASasquatch/was-node-suite-comfyui/, then pip install -r requirements.txt from inside that folder (or the portable build's embedded python equivalent), then restart ComfyUI.

      Common issues

      Nothing specific to this node tends to go wrong beyond the obvious: truncating by character can slice a word in half, which looks sloppy in a filename or a displayed caption - switch to word-based truncation if that's a problem for you, at the cost of the exact length no longer being guaranteed.

      The pack-wide issue to know about going in: WAS Node Suite hasn't been actively developed since December 2023, and the most common symptom of that is an "Import Failed" error after a ComfyUI update, because the pack's pinned dependencies can drift out of sync with what a newer ComfyUI or a sibling custom node expects. If that happens, reinstalling requirements.txt inside your ComfyUI venv is usually the fix; it's a real, recurring complaint in the community, not a one-off.

      Categoryx

      Inputs (0)

      No inputs

      Outputs (0)

      No outputs