Nodes/Skycoder Tools/Concatenate and Test if Empty
ComfyUI Node

Concatenate and Test if Empty

Join four strings, and find out in the same step if you joined nothing

By skycoder182·Created about a year ago·Updated about a year ago· 1
Concatenate and Test if Empty
    • is_empty
    • result
    text1
    text2
    text3
    text4

    Concatenate and Test if Empty does exactly two things, and it does them in one node: it glues together up to four text inputs into a single string, and it tells you whether that string ended up empty. That second half is the part worth having. "Is this prompt actually blank?" is a question you can't ask easily in a stock ComfyUI graph, and it's the key to building workflows that decide their own behavior.

    The obvious use is conditional prompt assembly. Build a prompt out of pieces - a style tag from one node, a subject from another, a LoRA trigger word from a third - then branch on whether the result is empty: if there's nothing to say, route around the text encoder and save the run; if there is, encode it and sample. It's the text equivalent of a sanity check before you let a workflow spend minutes on an empty prompt.

    How it works

    The node takes up to four optional strings, appends each non-null one in order, then compares the result against an empty string:

    result = ""
    for t in (text1, text2, text3, text4):
        if t is not None:
            result += t
    is_empty = result == ""
    

    Everything worth knowing is in that loop. Nothing gets skipped except None - empty strings still count as content (though they contribute nothing to result). And note there's no separator inserted: "cat" + "dog" becomes "catdog", not "cat dog". If you want spaces or commas between parts, you have to put them in the inputs yourself.

    Inputs and outputs

    • text1text4 (STRING, all optional) - the pieces to join. In practice these arrive as wires from upstream text nodes, so you can leave any of them disconnected.
    • is_empty (BOOLEAN) - the first output socket. True when the combined result is blank.
    • result (STRING) - the second output socket, the joined text itself.

    The output order trips people up: is_empty comes first, result second. It's easy to assume the string is on top and wire the boolean into a text sink (or vice versa). Look at the socket names, not positions.

    Installing it

    Part of the Skycoder Tools pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/skycoder182/comfyui-skycoder-tools.git
    # then restart ComfyUI
    

    Or ComfyUI Manager → "Install Custom Nodes" → search "Skycoder Tools" → Install → restart. No models, no special dependencies.

    Common issues

    The separator thing is the classic trap - if your joined prompt reads like one long word, that's by design, not a bug. The other one is treating "empty" as "whitespace only": a string of spaces isn't empty by this node's definition (" " == "" is false), so a prompt of pure whitespace will sail through as non-empty. If that matters, trim upstream. And remember it's optional-input based, so with nothing wired it returns ("", True) - an empty result and a true is_empty, which is the correct boring answer.

    CategoryCustom

    Inputs (4)

    NameTypeDefaultDescription
    text1optSTRING
    text2optSTRING
    text3optSTRING
    text4optSTRING

    Outputs (2)

    NameTypeDescription
    is_emptyBOOLEAN
    resultSTRING