Nodes/comfyui-dreambait-nodes/Dynamic String Concatenate πŸ”—
ComfyUI Node

Dynamic String Concatenate πŸ”—

Join strings without a fixed number of sockets

By drmbtΒ·Created 2 years agoΒ·Updated 7 months agoΒ· 6
Dynamic String Concatenate πŸ”—
    • concatenated_string
    • list_strings
    β—„delimiter, β–Ί
    β—„skip_emptytrueβ–Ί
    β—„trim_whitespacetrueβ–Ί

    Dynamic String Concatenate solves the most annoying property of ComfyUI text nodes: fixed input counts. A normal concatenate node gives you three or four string sockets and that's it - the moment you need a fifth, you either chain nodes or rework the graph. This one grows. Connect two strings, or twenty; new STRING sockets appear as you type in the last empty field. It's the "just works" text joiner the default nodes should have been.

    What it does

    Give it strings through its dynamic inputs and it joins them with a delimiter (default ", "). The settings that matter:

    • delimiter - anything you like. \n gives newlines; leaving it empty also gives newlines. It even parses the escape so you don't have to fight the widget.
    • skip_empty (default on) - empty or whitespace-only inputs are dropped instead of producing a, , b.
    • trim_whitespace (default on) - each input is stripped before joining, so " hello " joins as hello.

    Outputs are the useful part: concatenated_string (the joined result) and list_strings - the individual strings as a list. That second output is the sleeper feature: you get both the assembled paragraph and the components for anything that wants a list (loops, batching, per-item processing).

    How it behaves under the hood

    The source is honest about being a pragmatic utility. Non-string inputs are coerced with str(), so a number socket that lands on a string input doesn't crash the workflow - it just gets stringified. Delimiter parsing handles \n literally (you type \n and get a real newline). And because inputs are keyed by name (STRING1, STRING2, …), ordering follows the socket order you see in the UI rather than insertion chaos.

    When you'll reach for it

    This is a build-your-prompt workhorse. Typical use: a base style string, a subject, a quality tag, a LoRA-trigger phrase - each from its own source (another node, a saved preset, a wildcard) - all joined into one positive prompt. Because it's dynamic, adding a "negative prompt component" or a second subject later is just one more socket, not a rebuild. The list output also makes it a natural partner for the pack's list utilities: generate a list of candidate prompts, join them with a delimiter, feed to a batch.

    One gotcha to keep in mind: since sockets appear as you type, it's easy to accidentally leave an empty STRING3 sitting in your workflow - harmless with skip_empty on, but if you ever turn it off, an empty input can inject a stray delimiter into your prompt. Leave skip_empty on unless you have a reason not to.

    Install

    It ships in drmbt/comfyui-dreambait-nodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/drmbt/comfyui-dreambait-nodes
    

    then restart ComfyUI (or ComfyUI Manager, search "comfyui-dreambait-nodes"). The usual pack caveat applies: the install brings the full dependency list, ML deps included, even though this node is plain string handling. But if you already run the pack, it's one of the first nodes you'll actually use - the default text tools just don't do dynamic joins.

    Categoryutils

    Inputs (3)

    NameTypeDefaultDescription
    delimiteroptSTRING, Character(s) to separate the input strings. Use \n for newlines. Leave empty for newlines. Default is ', '.
    skip_emptyoptBOOLEANtrueIf enabled, empty or whitespace-only strings will be skipped during concatenation.
    trim_whitespaceoptBOOLEANtrueIf enabled, leading and trailing whitespace will be removed from each input string before concatenation.

    Outputs (2)

    NameTypeDescription
    concatenated_stringSTRINGβ€”
    list_stringsSTRINGβ€”