String Strip
Scrub the stray whitespace out of your prompts
- string
If you've ever pasted a prompt from a website or a chat model into ComfyUI and watched the CLIP encode do something subtly wrong, the culprit was usually invisible: a stray newline or a couple of leading spaces. String Strip is the boring fix you didn't know you needed. It's one input, one output, no settings - the string-util pack's answer to "please just clean this text up."
What it does
String Strip runs Python's str.strip() on whatever string you feed it. That strips whitespace from both ends - spaces, tabs, newlines - and nothing else. The text in the middle is left completely alone. So " a masterpiece, best quality\n" becomes "a masterpiece, best quality".
Why bother? Because whitespace is the quiet saboteur of text pipelines. LLM-generated prompts arrive with trailing newlines. Copied tag lists carry leading spaces. If you're building a prompt from multiple pieces - say, appending style tags to a subject string - a hidden newline can make two strings join in a way you didn't intend. Run the pieces through String Strip before you concat or encode, and the graph behaves.
The inputs and outputs
There's exactly one of each:
s(STRING) - the text to clean. Wire in anything string-typed.string(STRING) - the same text with leading and trailing whitespace removed.
That's the whole node. It's a straight pass-through otherwise.
How to install it
This pack is tiny and dependency-free: no requirements.txt, no model downloads, nothing to compile. Install it via ComfyUI Manager (search "ComfyUI-string-util") or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-string-util
Then restart ComfyUI. The node shows up under the string-util category in the node menu.
Common issues
The only real gotcha is expectation: strip() trims the ends, not the middle. "a b" stays "a b" - you'd need Replace for that, which the same pack provides. Also note that an empty string passes through as empty; there's no error, it just does nothing.
One thing worth knowing: if you only need to clean one side, the same pack has String Lstrip (leading only) and String Rstrip (trailing only). For most prompt-cleaning jobs the full strip is what you want, but when a filename or a fixed prefix is involved, the one-sided versions are the precise tool.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| s | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |