ComfyUI Node

Append String

The Clean Way to Glue Two Prompts Together Without ,, or Doubled Tags

By younyokel·Created about a year ago·Updated about a year ago· 6
Append String
    • STRING
    string1
    string2
    commatrue
    dedupetrue

    Every ComfyUI user eventually hits the same mess: you want to build a prompt out of pieces - a base prompt from one node, quality tags from another, a LoRA trigger phrase on top - and the naive approach dumps masterpiece,, best quality, ,1girl into your CLIP Text Encode. "Append String" (TextAppendFormatter) is the smallest, most honest fix for that. It takes two strings, joins them, and tidies the seam: trims stray commas and spaces, and can skip tags that already exist. No buttons, no magic - just string surgery.

    How it works

    combine(string1, string2, comma, dedupe) does three things in order. First, if dedupe is on (it is by default), it splits both strings on commas and drops any tokens from string2 that already appear in string1 - so appending masterpiece, best quality to a string that already has masterpiece only adds best quality. Then it strips trailing commas/space off string1 and leading ones off string2. Finally it joins them with ", " if comma is on, or a single space if you turned it off. Empty inputs are handled gracefully: if either side is empty, you get the other side back, no orphan commas.

    The dedupe is worth being precise about: it compares whole comma-split tokens. That's exactly right for Danbooru-style tag lists (1girl, long hair) where each token is a discrete tag. It's near-useless for prose, where the "tokens" are entire sentences and nothing ever matches. If your string2 is a full sentence, dedupe does nothing and that's fine.

    The inputs that matter

    • string1 and string2 - both are forceInput fields, meaning you're expected to wire other nodes into them (a TextOnlyFormatter output, a wildcard node, whatever) rather than type. Both default to empty.
    • comma (bool, default on) - add , between the parts.
    • dedupe (bool, default on) - drop string2 tokens that already exist in string1.

    Output is a single STRING, ready for a CLIP Text Encode's text input or any other text socket.

    Why you'd actually reach for it

    It's a plumbing node, and it shines in exactly one setup: prompts assembled from modular parts. Quality prefix from one place, subject from another, LoRA trigger from a third, all merged without you hand-editing commas. It pairs naturally with the pack's own TextOnlyFormatter, which can format and dedupe the base prompt before it arrives here. If you're on a Danbooru-tag model (Illustrious, NoobAI), the dedupe option quietly prevents the same tag from landing twice in your conditioning - a real, if small, quality win. On prose models it's just a tidy concatenator, and there are plenty of those around; this one is fine but unremarkable there.

    One honest note: it's the least distinctive node in the pack - the formatting buttons don't appear on it, and its logic is simple enough to hand-roll in any number of text nodes. You install the pack for the formatter buttons and pick this up as a convenience.

    Install

    No extra steps beyond the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/younyokel/comfyui_prompt_formatter.git
    

    Restart ComfyUI, and it's there - no dependencies, no models, nothing else to pull. Or grab ComfyUI Prompt Formatter from the ComfyUI Manager registry. There's no community troubleshooting trail for this one; it's small enough that the README plus a glance at the node's few lines of logic covers everything that can go wrong.

    Categoryprompt_formatter

    Inputs (4)

    NameTypeDefaultDescription
    string1STRINGFirst string.
    string2STRINGString to append.
    commaBOOLEANtrueAdd comma between strings.
    dedupeBOOLEANtruePrevents appending tokens from string2 if they already exist in string1.

    Outputs (1)

    NameTypeDescription
    STRINGSTRING