DP 5 Find And Replace
Five find/replace passes over your prompt in one node
- TEXT
Sometimes you want the same prompt with a few words swapped, without maintaining five near-identical copies of it. This node takes one text input and runs up to five find-and-replace operations on it in a single pass. Set up your placeholders once, change them in one place, and every downstream generation follows.
It's from DesertPixelAi's Desert-Pixel-Nodes, a large quality-of-life pack - utility nodes that don't generate anything, they just make text and workflow wrangling easier. The clever bit is how it pairs with template prompts: the default find values are placeholder tokens (#rep1 through #rep5), so you write a prompt full of those tokens and let this node fill them in.
How it works
You write a template with placeholder tokens in it - something like "a #rep1 cat in a #rep2 room" - and wire that into the node. Then each of the five find/replace pairs says "wherever you see #rep1, put this instead." All five substitutions run on the input text and the result comes out one string.
That placeholder pattern is what makes it more than a text editor. Because #rep1…#rep5 are the defaults, you can build a reusable prompt skeleton and drive the variable parts from these five slots - or from upstream nodes wired into the replace fields. The pack's README bills the node as supporting regex, so more advanced patterns than plain-text swaps are on the table if you need them.
The inputs and outputs that matter
01_find…05_find- the text to search for. Defaults are#rep1through#rep5, which double as ready-made placeholder tokens.01_replace_with…05_replace_with- what each match gets replaced with. Empty by default, so an unset pair effectively deletes its placeholder.Text- the optional input string the replacements run on. Wire your template prompt here.
The output is TEXT (a string). Send it to a CLIP Text Encode, a prompt cleaner, or a save node.
How to install it
- ComfyUI Manager: search "Desert Pixel", install, restart. Nothing to download.
- Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/DesertPixelAi/ComfyUI-Desert-Pixel-Nodes,pip install -r requirements.txtif present, restart.
Look under the DP category.
Common issues
The big one: leftover placeholders. If your template has #rep1 but you never set 01_replace_with to anything, the token either stays in your prompt or gets replaced with nothing, depending on your setup - and a literal #rep1 sitting in your prompt is just noise the encoder reads. After a batch of replacements, it's worth running the result through DP_Clean_Prompt to tidy up any gaps left behind by empty replacements.
The other thing to watch is that find is case- and substring-sensitive. If your placeholder is #rep1 but you typed #Rep1 in the template, it won't match. And because these are substring replacements, a find value that appears inside a word you didn't mean to touch will get swapped too - pick placeholder tokens (like the #-prefixed defaults) that won't accidentally collide with real prompt words.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| 01_find | STRING | #rep1 | — |
| 01_replace_with | STRING | — | |
| 02_find | STRING | #rep2 | — |
| 02_replace_with | STRING | — | |
| 03_find | STRING | #rep3 | — |
| 03_replace_with | STRING | — | |
| 04_find | STRING | #rep4 | — |
| 04_replace_with | STRING | — | |
| 05_find | STRING | #rep5 | — |
| 05_replace_with | STRING | — | |
| Textopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TEXT | STRING | — |