Empty String Replacement (Soze)
Swap in a fallback only when the input is actually blank
- output_string
A small coalesce node: if a string is empty, swap in a fallback; otherwise leave it alone. Nothing clever, but it plugs a real gap - anywhere a value flows from something that might legitimately be blank (an optional CSV column, a JSON field that wasn't set) and you'd rather have a sensible default than an empty prompt silently reaching your sampler.
It belongs to the same small family of string utilities as this pack's Multiline Concatenate, Multi Find And Replace, and Text Contains nodes - none of them individually dramatic, but they're the kind of glue that makes a CSV- or JSON-driven batch pipeline actually robust instead of breaking on the first row with a gap in it.
How it works
Checks whether input_string is empty. If it is, the node outputs empty_string_replacement instead. If it isn't, input_string passes through completely unchanged.
The inputs and outputs that matter
input_string(STRING, required) - the value to check.empty_string_replacement(STRING, required) - what to use ifinput_stringcomes through empty.- Output:
output_string- either the original value or the fallback.
How to install it
Via ComfyUI Manager: search "Quality of Life Nodes for ComfyUI", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/SozeInc/ComfyUI_Soze.git
pip install -r ComfyUI_Soze/requirements.txt
No dependencies, no API key - pure string logic.
Common issues & troubleshooting
Whitespace-only strings still count as "not empty." If the node's notion of empty is a strict length check (the ordinary behavior for a node like this), a string that's just a space or two won't trigger the replacement even though it's functionally blank. If you're feeding this from a CSV or JSON source that sometimes leaves trailing whitespace instead of a truly empty field, trim upstream if that matters to you.
You're driving a CSV batch and some rows leave a column blank. This is the node's natural home - wire that column's CSV Reader output through Empty String Replacement with a sensible default prompt or tag, so a blank cell in row 47 doesn't quietly turn into an empty prompt three nodes later.
The fallback itself needs to vary. It doesn't here - empty_string_replacement is a single fixed value per node instance. If you need different fallbacks in different situations, that's multiple Empty String Replacement nodes, one per case, not one smart node.
You're chaining several of these and it's getting hard to follow. That's a sign you've got several independently-optional fields feeding one prompt. Consider whether a Multiline Concatenate node downstream, building the final string out of pieces that are each already defaulted, reads more clearly than a long chain of separate replacements feeding into each other.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| input_string | STRING | — | |
| empty_string_replacement | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output_string | STRING | — |