isspace
Isspace — the honest answer to 'is this prompt actually blank?'
- BOOLEAN
In ComfyUI, an empty text field isn't None and it isn't missing - it's "". And sometimes it's worse than that: a string that looks empty but is actually five spaces, or a tab, or a newline that came in from a file. isspace is the node that tells you whether a string is effectively blank, whitespace and all. It's the "did the user actually type anything" check for text that has been sitting in a workflow long enough to pick up cruft.
You'd reach for it to gate a prompt: if the text is all whitespace, route to a default prompt or skip generation rather than sampling on garbage. It also catches failed reads and empty API responses that come back as whitespace instead of truly empty strings.
How it works
Python's str.isspace(). Returns True when the string is non-empty and every character is whitespace. Whitespace here is generous - spaces, tabs, newlines, and a bunch of Unicode space characters all count:
" "→True" \t\n"→True"\u2003"(an em space) →True"a "→False""→False
That last one matters. Because the string must be non-empty, a truly empty string returns False. So isspace alone can't catch both cases - it catches whitespace-only text, but not the empty string. If you want "is this blank OR whitespace", you need two checks.
Inputs and outputs
One required input, string (default ""), one BOOLEAN output. Wire the output into a conditional: True means "treat as blank", so you can feed in a default value on that branch.
Installing it
Part of the Basic data handling pack by StableLlama. ComfyUI Manager, search "Basic data handling", install, restart. Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
The pack has no dependencies and downloads nothing - one of the rare installs that can't get you into dependency hell, which is why it rides along in so many shared workflows. Node lives under Basic/STRING/is.
Common issues
The gap is empty-vs-whitespace. "" gives you False, which is the opposite of what a "is this blank" instinct expects. The fix is to combine it with a length check: this pack's length node returns 0 for "", so length == 0 OR isspace is the complete blank-detector. People also forget that whitespace detection includes the invisible Unicode spaces - which is usually a feature (it catches em-space pasted from a web form), just don't be surprised when a string that displays as blank is flagged True.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | — |