ComfyUI Node

Simple Text Truncate

Cut a string down to N words without thinking about it

By robertvoy·Created 2 years ago·Updated 9 months ago· 239
Simple Text Truncate
    • TEXT
    text
    word_count10

    Some nodes exist to be clever. This one exists to be boring, and that's its charm. Simple Text Truncate takes a STRING, keeps only the first N words, and hands back the trimmed result. Default is 10 words; you can set any count from 0 up to a ludicrous 99999999, which is ComfyUI's way of saying "basically unlimited." It does exactly what it says and nothing else.

    What it's actually for in the Continuum workflow

    In the shipped 1.7.0 workflow, its output feeds the filename input of a Save Image Grid node. Think about that for a second: long descriptive prompts make terrible filenames - enormous, full of spaces, unwieldy in a folder. Truncating the prompt to a few words before it becomes a filename turns photorealistic portrait of a woman in golden hour light, cinematic bokeh, 85mm lens, soft shadows into something you can actually read in a file manager. It's a quiet little quality-of-life trick that every filename-minded workflow should copy.

    Outside that, the same logic applies anywhere text gets too long for its destination: filenames, labels on an image, preview text, or any downstream node with a character budget. It's also a cheap way to summarize - take a long prompt and keep just the subject words. Crude, but sometimes all you need is the head of the string.

    How it works (and one edge case)

    The mechanism is a simple split-and-slice: it splits the string on whitespace and joins the first word_count words back together. That means it counts words, not characters - "10 words" can still be a long string if the words are long. If you need a character cap, this isn't the node.

    One detail worth knowing: the text input is a forced input (forceInput), so it comes in as a wire rather than an editable text box on the node - that's what makes it useful mid-pipeline. And if the input is None (nothing connected), it returns an empty string instead of crashing, which is a small nicety that saves you a red node. The word_count input is an integer widget on the node, so you can tune it in place.

    Install

    It ships with Flux Continuum:

    cd ComfyUI/custom_nodes
    git clone https://github.com/robertvoy/ComfyUI-Flux-Continuum
    

    Restart ComfyUI, or install via ComfyUI Manager → search "Flux Continuum". No dependencies.

    Troubleshooting

    • Output is empty even with text connected - word_count is probably 0, which truncates everything. Set it to 1 or more.
    • Text not arriving - remember text is an input wire, not a widget; connect a prompt or text node to it.
    • Filename still long - 10 words is a decent default, but the node counts words, so long words slip through. Lower the count.

    It's a one-job node, and it does that one job cleanly. Add it anywhere a long string needs to shut up and be short.

    CategoryText Operations

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    word_countINT100–99999999

    Outputs (1)

    NameTypeDescription
    TEXTSTRING