Nodes/comfyui-darkil-nodes/Text is empty [darkilNodes]
ComfyUI Node

Text is empty [darkilNodes]

The boolean gate that knows whitespace-only text is still empty

By pytraveler·Created 7 months ago·Updated 15 days ago· 9
Text is empty [darkilNodes]
    • BOOLEAN
    text

    Prompt-conditioning workflows have an endless need for "is there actually a prompt here, or did that branch come up empty?" This node answers it with a boolean: text in, True out if the text is empty - and, crucially, its definition of empty is stricter than you'd guess. Whitespace-only text counts as empty, and so does a string made entirely of semicolons. That's not an accident; it's the behavior that makes the node useful for gate logic instead of a naive len(text) == 0 check.

    How it works

    Under the hood it strips spaces, newlines, carriage returns, tabs and semicolons from the input and returns True if nothing survives. So "", " ", and ";;;" all return True, while " " followed by any actual character returns False. It also treats non-string input (say, a number that got wired in) as not-empty, which is a reasonable "there's something here" default.

    The output is a single BOOLEAN. Wire it into a logic switch, a conditional, or an any-switch that picks between two branches depending on whether a prompt fragment exists. Paired with the pack's Text not empty node, you've got both polarities of the same gate.

    Why you'd reach for it

    This is a plumbing node, not a headline feature - but plumbing is what keeps workflows from collapsing. A classic use: a workflow where an optional LoRA trigger or style block may or may not produce text; you gate the positive prompt on Text not empty and the cleanup pass on Text is empty, so the graph does different work depending on what actually arrived. Because the whitespace handling is built in, you don't get false "empty" readings from templates that leave trailing newlines - which is exactly the failure mode that sends people down rabbit holes with naive checks.

    Where people get burned

    Honestly, not much to trip on here. The one surprise is the semicolon behavior - if your text legitimately contains only punctuation, it reads as empty, which is correct for the pack's own variable syntax but may be unexpected if you're checking, say, a raw CSV line. And remember the output is a boolean value, not a UI toggle - it won't flip a node on or off by itself unless you feed it into a switch.

    Installing

    It ships in pytraveler/comfyui-darkil-nodes. ComfyUI Manager search ComfyUI-darkil-nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/pytraveler/comfyui-darkil-nodes
    

    Restart ComfyUI. No Python deps, no models - a pure text predicate.

    CategorydarkilNodes/text

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN