Nodes/comfyui-yanc/Concatenate Strings
ComfyUI Node

Concatenate Strings

Join Two Strings With a Separator in ComfyUI

By ka-puna·Created 3 years ago·Updated 11 months ago· 12
Concatenate Strings
    • STRING
    separator
    a_optional
    b_optional

    Concatenate Strings does exactly one thing: it glues two strings together with a separator in between. That's the whole node. If you're wondering why that needs to be its own node instead of just typing the text you want, the answer is that in ComfyUI those two strings are usually not things you typed - they're values coming out of other nodes, and this is the connector that stitches them into one string you can actually use somewhere else, most often a filename.

    That's the context this node lives in. It's one of six small utility nodes from comfyui-yanc ("Yet Another Node Collection"), a pack by ka-puna built around a specific annoyance: most custom node repos give you a pile of nodes when you wanted one, and big repos break your workflows when they update in ways you didn't ask for. So yanc is the opposite - one Python file per node, nothing shared between them except a loader script (credited to pythongosssss, who later became one of the founding Comfy Org team members working on ComfyUI's own frontend). Add or remove a file, add or remove a node. Several of yanc's nodes - Get Widget Value String, Format Datetime String, Truncate String, Integer Caster - exist specifically to build up a string piece by piece, and ConcatStrings is the glue that actually assembles them before the result lands in something like Save Image as WEBP's filename field.

    How it works. The node takes a required separator (a plain string, defaults to empty) and two optional inputs, a_optional and b_optional. Leave either one unplugged and it's treated as an empty string - not omitted, just blank. The output is always a + separator + b, in that order, every time. That last part matters more than it sounds: if you leave b_optional disconnected but set a separator, your separator still shows up at the end of the output. "render" + "_" + "" gives you render_, not render. Worth knowing before you're staring at a trailing underscore in your filenames wondering where it came from.

    Inputs/outputs. separator (required, STRING), a_optional and b_optional (optional, STRING) in; one STRING out. That's the entire interface - no tooltips beyond the field names, and none needed.

    Because it only takes two string inputs, gluing together three or more pieces means chaining nodes: run the output of one ConcatStrings into the a_optional of the next. It's a little more clicking than a node that took five inputs, but it also means you're never staring at a wall of unused sockets - pretty on-brand for a pack whose whole pitch is "small and legible."

    Installing it. Easiest path is ComfyUI Manager: search "comfyui-yanc" (or just "yanc"), install, restart ComfyUI. By hand, it's the standard drill -

    cd ComfyUI/custom_nodes
    git clone https://github.com/ka-puna/comfyui-yanc
    
    • then restart. There's no requirements.txt, no model downloads, nothing to configure. Everything in this pack is plain Python; ConcatStrings itself is a one-line string join.

    Troubleshooting. There isn't much that goes wrong with a string join, so the real gotchas live upstream of it. If you're feeding it the output of Get Widget Value String and that node can't find the target - wrong node name, wrong widget name - it raises an error and halts the queue before ConcatStrings ever runs, so a blank/missing input here is more likely a symptom than the actual bug. And if your final filename comes out with a stray separator at the start or end, check which side of a ConcatStrings chain is actually empty rather than assuming the node malfunctioned - it's doing exactly what it's told, which is to always put the separator in, connected or not.

    Categoryutils

    Inputs (3)

    NameTypeDefaultDescription
    separatorSTRING
    a_optionaloptSTRING
    b_optionaloptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING