Nodes/comfyui-mdsnodes/Merge Two Strings
ComfyUI Node

Merge Two Strings

Stitch prompts and filenames together the easy way

By MarwanDSAI·Created 20 days ago·Updated about 23 hours ago· 1
Merge Two Strings
    • merged_string
    string_a
    string_b
    delimiter

    String handling in ComfyUI is where the "programming language with no keyboard" part starts to show its age. You want a prompt assembled from a base plus a style tag, or a filename built from a model name plus a seed, and suddenly you're eyeing a script node. Merge Two Strings (class name MarMergeTwoStrings) is the small, honest solution: two strings in, one string out, with a delimiter that only appears when it should. No regex, no code, no learning curve.

    The inputs are all optional: string_a and string_b are sockets (wired connections) that default to empty, plus a delimiter text box that defaults to a single space. Wire nothing and the output is an empty string; wire one side and you get that side back untouched. The clever part is the delimiter logic: it's inserted only when both strings have text. So "Hello" + "world" with the default space gives "Hello world", but "Hello" + "" gives just "Hello" - no dangling space or separator at the end. That's the detail that makes it feel designed rather than thrown together, and it's why the node is nice for building things that might legitimately be missing a piece.

    Under the hood it's exactly what the tooltips say: None or unconnected inputs are treated as empty strings, and everything gets str()-ed first, so you can throw a number at it without drama. One honest gotcha: it .strip()s both inputs, trimming leading and trailing whitespace. Usually that's what you want - most people don't mean to keep stray spaces - but if you're preserving deliberate formatting, know it's happening.

    What is it actually good for? Building prompt fragments from parts and feeding them into a CLIP Text Encode. Making a SaveImage filename prefix like "checkpoint_seed42" by merging a model name with a seed converted to text. Combining two tag strings before they go into metadata. It plays especially well with its packmates - Convert to String on one side, Metadata Append on the other, Merge Two Strings in the middle - which makes sense, because all three live in the same tiny text-tools corner of comfyui-mdsnodes.

    That pack is the supporting cast for the author's Ultimate Model Tester Workflow on Civitai, and this node arrived in v1.1.0 as part of its text toolbox. It's a two-input-only node - if you need to join three or more fragments, chain two of them (the output feeds the next one's string_a). Installation is the same lightweight story as the rest of the pack: no extra Python dependencies, nothing to download. In ComfyUI Manager, search ComfyUI-MDSNodes, install, restart, and you'll find "Merge Two Strings" under MDSNodes → Text.

    cd ComfyUI/custom_nodes
    git clone https://github.com/MarwanDSAI/comfyui-mdsnodes
    

    If the output isn't what you expected, check the delimiter first - the default is a space, and a ", " or "-" often reads better in filenames. And remember the strip: inputs come back trimmed, so "Hello " and " world" still merge cleanly to "Hello world". Nothing flashy here, but it's the kind of node you'll reach for constantly once you've used it once.

    CategoryMDSNodes/text

    Inputs (3)

    NameTypeDefaultDescription
    string_aoptSTRINGFirst input string. If disconnected or None, treated as empty.
    string_boptSTRINGSecond input string. If disconnected or None, treated as empty.
    delimiteroptSTRING Delimiter added between string_a and string_b only when both contain text.

    Outputs (1)

    NameTypeDescription
    merged_stringSTRINGThe merged output string, or an empty string if both inputs are empty.