Nodes/ComfyUI-UniversalToolkit/Text Concatenate (UTK)
ComfyUI Node

Text Concatenate (UTK)

Glue up to four strings into a prompt

By whmc76·Created about a year ago·Updated 2 months ago· 72
Text Concatenate (UTK)
    • STRING
    delimiter,
    clean_whitespace
    text_a
    text_b
    text_c
    text_d

    Most serious workflows end up assembling prompts from parts - a base prompt, a style block, a LoRA's trigger phrase, a dynamic bit from a randomizer or an LLM node - and you need a junction where those strings become one. Text Concatenate joins up to four input strings with a delimiter you choose, strips whitespace if you ask, and skips empties so your prompt doesn't end up with trailing commas everywhere. It's the smallest piece of prompt plumbing you'll use, and you'll use it constantly once you've got a modular prompt setup.

    How it works

    It takes the strings wired into text_a through text_d, joins them in alphabetical order with the delimiter, and returns one STRING. A few details matter:

    • Empties are skipped. Blank inputs never produce stray delimiters. Feed it two of four inputs and you get a clean two-part string.
    • clean_whitespace is a real trim. With it on, each input is .strip()-ed before joining, which fixes the classic "prompt has a leading space because the source node added a newline" annoyance.
    • The delimiter special-cases newlines. Type \n and it becomes an actual line break - useful if you're building multi-line conditioning or a caption, not a comma-joined prompt.
    • Order is alphabetical, not visual. It sorts by input name (a, b, c, d), which is the same as reading order if you label your inputs sensibly. Don't expect the order to follow how you arranged the wires on the canvas.

    The inputs and output

    • delimiter (default ", ") - the separator between parts.
    • clean_whitespace - an enum of "true" / "false" (yes, it's a string enum, not a real boolean - pick "true" and it strips).
    • text_a / text_b / text_c / text_d - the strings to join. All optional, and all input-only: these fields are forceInput, meaning you can't type into them, you have to wire them. That's exactly why a plain TextBox (UTK) node pairs so well with this one.

    One output, STRING, ready to feed a CLIP Text Encode or a prompt builder.

    Installing it

    Shared pack install - ComfyUI Manager (search "ComfyUI-UniversalToolkit") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/whmc76/ComfyUI-UniversalToolkit
    pip install -r requirements.txt
    

    Pure Python, no extra dependencies.

    Where people get burned

    • You can't type into the text inputs. If you add the node and find four empty input ports with no widgets, that's by design. Feed them from TextBox nodes or any string source.
    • The clean_whitespace "boolean" is a dropdown. If you're used to a real toggle, the "true"/"false" text values read oddly, but that's how it's defined.
    • If your merged prompt looks like style base instead of base, style, you've hit the alphabetical ordering - rename the feeding nodes' outputs or reorder which letter carries what.

    It's not exciting, but for prompt assembly it's the difference between a clean graph and a rats' nest of concatenation hacks.

    CategoryUniversalToolkit/Text

    Inputs (6)

    NameTypeDefaultDescription
    delimiterSTRING,
    clean_whitespaceCOMBO2 options: true, false
    text_aoptSTRING
    text_boptSTRING
    text_coptSTRING
    text_doptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING