Replace Text _O
Find-and-replace for your prompts
- STRING
You've got a working prompt, and you want a variant without rewriting the whole thing: swap the subject, strip a tag, fix a typo that appears in ten places. Replace Text _O is the find-and-replace node for strings - give it text, an old substring, and a new replacement, and out comes the modified string.
It's in the Quality of Life Suit's O/text/operations group, and it slots neatly into the pack's prompt-engineering story. Wire a base prompt into text, hook a ChatGPT-generated or manually typed old/new pair in from other text nodes, and you've got prompt variants you can build and swap without touching the main prompt string. Paired with QOL Split String and Concat Text _O, you can assemble, break apart, and rewrite prompt pieces entirely from wired nodes.
How it works
The mechanism is Python's str.replace() under the hood. Two things that behavior implies, and both will surprise you if you don't expect them:
- It replaces all occurrences. If
oldappears five times, all five get replaced. There's no "first match only" option. Usually that's what you want (that's what makes it useful for cleaning up a repeated typo), but it means you can't surgically change one instance in a list of similar tags. - It's a literal substring match, case-sensitive.
"flower"will not match"Flower". It's also not a regex, so"cat.*"is literally the charactersc-a-t-.*, not a wildcard. If you need regular expressions, this isn't the node - reach for a Python-expression utility instead.
One genuinely useful trick: replace with an empty string to delete a substring. Want to drop , watermark from every prompt in a batch? old=", watermark", new="". That's the closest this node gets to a "remove" button.
The inputs that matter
text- the string to operate on (multiline).old- the substring to find.new- what to replace it with (empty is allowed and useful).
Output: a single STRING.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92.git
or ComfyUI Manager → search ComfyUI-QualityOfLifeSuit_Omar92, then restart ComfyUI. No dependencies.
Gotchas
Watch the empty-match edge case: if old is an empty string, str.replace("", x) inserts x between every character - almost never what you intended. And remember the ordering when you chain replacements: since each pass sees the output of the last, a replacement that itself contains old text will keep matching. For straightforward prompt editing, none of that will bother you - it just works.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| old | STRING | — | |
| new | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |