String Strip
Scrape the boilerplate off LLM prompts before they hit the sampler
- modified_string
If you've ever pasted an LLM's idea of a prompt into ComfyUI and watched it render the words "Sure, here is your prompt:" into the image, you know exactly why String Strip exists. It removes strings from text - a whole list of them, one per line, multi-word phrases allowed - and it's tuned for the specific garbage that language models add to image descriptions and prompts.
The intended job is right in the README: cleaning text from Ollama, Claude, or ChatGPT before it reaches the sampler. Those models wrap their output in courtesies ("Here is a detailed description:", "Certainly! Let me..."), trailing notes, and markdown fences. String Strip is the machete. You type the offending phrases one per line - Here is a detailed description:, Certainly!, image/prompt: - wire in the LLM text, and out comes a clean prompt.
How it works
Each non-empty line of strings_to_remove becomes a removal rule, and the node applies them in longest-first order so a phrase like "This image is" gets removed before "is" can shred the rest of the sentence. Matching is case-insensitive by default, and match_whole_string (on by default) uses word boundaries so art doesn't tear apart artistic. Two cleanup flags ride along: preserve_punctuation keeps the commas and periods hugging the removed text instead of eating them, and remove_extra_spaces collapses the double-spaces that removals leave behind.
The inputs that matter
strings_to_remove- one string per line. A multi-word phrase on a single line only matches that entire phrase, which is the right way to avoid nuking half the prompt.match_whole_string- on by default. Flip it off if you genuinely want substring removal.match_case- off by default; turn on for case-sensitive removal.preserve_punctuation/remove_extra_spaces- both on by default, and you'll rarely touch them.
Output: a single modified_string. Wire it into String Preview to confirm the result, then on to the sampler.
Installation
Zero Python dependencies (it's standard-library re under the hood), no model files. Via ComfyUI Manager: Manager > Custom Nodes Manager > search "ComfyUI_StringEssentials" > Install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/bradsec/ComfyUI_StringEssentials.git
Restart, then find it under Add Node > utils > StringEssentials.
Gotchas
- This node only removes - it doesn't swap. For replacing text with new text, reach for String Multi Replace in the same pack. Deleting and replacing are separate tools here.
- Word boundaries use regex
\b. That's mostly great (artwon't touchartistic) but note that underscores count as word characters, sophotowon't match insidephoto_realistic- something to remember if you're stripping tag-style text. - Case-insensitive by default.
Here isin your list will removeHERE ISandhere is. If the case distinction matters, setmatch_caseon. - Everything you list is matched literally - regex metacharacters are escaped for you, so you can list
(word:1.3)or[A1111:Forge:.5]without worrying about the brackets meaning anything. That's a deliberate feature: prompt syntax survives the cleaning. - If a removal isn't happening, the usual cause is
match_whole_stringblocking it because the phrase sits mid-word - or the phrase isn't actually verbatim in the text. Preview first, adjust after.
For anyone routing LLM output into ComfyUI - which increasingly means everyone - this is the node that turns a garbage sentence into a sampler-ready prompt.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| input_string | STRING | The string to process | |
| strings_to_remove | STRING | Enter strings to remove (one per line). Can include multiple words or strings on one line like: 'This image is'. This will only match this entire string. | |
| match_case | BOOLEAN | false | When enabled, matching is case-sensitive. |
| match_whole_string | BOOLEAN | true | When enabled, only whole-word matches are removed, not substrings inside other words. |
| preserve_punctuation | BOOLEAN | true | When enabled, punctuation marks adjacent to matched text are preserved |
| remove_extra_spaces | BOOLEAN | true | When enabled, collapses repeated spaces and trims the result after removal. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| modified_string | STRING | — |