Nodes/ComfyUI-TinyBee/Empty String To Null
ComfyUI Node

Empty String To Null

Use an empty prompt as an off-switch instead of building a bypass

By TinyBeeman·Created about a year ago·Updated 10 days ago· 1
Empty String To Null
    • string
    string

    Here's a pattern that drives people to build ugly switch nodes: "I want this branch of my workflow to do nothing sometimes." The elegant way to express that in ComfyUI is with None - leave an optional input unconnected and it arrives as None, and a first-non-null switch skips it. The problem is getting a human-friendly control (a blank text box) to produce that None. That's the whole job of Empty String To Null.

    Give it a string. If that string is empty (or only whitespace), it outputs None. If it has any real content, it passes the string through untouched. That's the entire mechanism, and it's the kind of node that feels pointless for a week and then saves you one afternoon of spaghetti.

    How it fits a real workflow

    Say you have a prompt-rewrite step - an LLM node or a style modifier - and you want to be able to turn it off by just clearing its prompt. Wire the rewrite into Empty String To Null, then into an Any Switch-style fallback that picks the first non-empty input (that pattern is well-covered in ComfyUI's plumbing layer). Empty prompt → None → switch skips it → the unmodified text wins. Non-empty prompt → string passes through → switch takes the rewrite. You've built a bypass with a text box and zero bypass nodes.

    The reverse pairing is Null To String in the same pack, which turns None back into "" for downstream nodes that can't handle None. The two are designed as a set, and they're the reason this little pack's casting category exists - ComfyUI is loose about None flowing through wires, but it's strict about the moment it hits a node that expected a string.

    The input and output

    One required string input (force-input, so it arrives as a socket - you can't type into this node directly) and one string output. Like its sibling, it returns float("NaN") from IS_CHANGED, meaning it always reruns. That's intentional: whether the text is empty can change between runs without the input widget changing, and the node's whole point is to react to that. It's cheap, so don't worry about the cache hit.

    Install and gotchas

    Standard TinyBee pack install - ComfyUI Manager, search "ComfyUI-TinyBee", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    then restart ComfyUI. No models, no GPU, no dependencies beyond the pack's light pillow/jsonata requirements.txt. The only real gotcha is semantic: this produces None, and not every node accepts a None-typed wire on its socket. If you see a type error, the answer is usually Null To String on the far side, not a workaround. And remember the whitespace rule - " " counts as empty, which is usually what you want but worth knowing when a prompt that "looks empty" quietly passes through.

    Category🐝TinyBee/Casting

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    stringSTRING