Simple String Replace
Find-and-replace for prompts, with the malformed lines actually reported
- text
- ignored_lines
Plain find-and-replace on a string is a boring capability, and that's exactly why you want a node that does it without surprises. Simple String Replace takes text plus a list of find => replace pairs and applies them in order, so you can normalize a prompt in one pass: swap "girl" for "woman", strip a style tag, turn " hi res " into " 8k". The output is a clean string your CLIP encoder can actually use.
The detail that separates this from a hand-rolled string hack is honesty about failure. When a line in your pairs list is malformed - missing the =>, or with an empty find side - the node doesn't silently drop it. It collects those lines and hands them back on a second output called ignored_lines. You always know what didn't apply, instead of discovering it three images later when your replacement mysteriously never happened.
The inputs and outputs that matter
text- the source string.find_replace_pairs- a multiline text box, one pair per line infind => replaceformat. The defaults (find => replace,old => new) make the syntax obvious. Empty replacement removes text, soremove_this =>deletes it. Lines starting with#are treated as comments and skipped.whole_word_match- the optional toggle worth knowing. Off, and it's a plain substring replace (socatmatches insideconcatenate). On, it uses regex\bword boundaries and only matches complete words.- Outputs:
text(the result) andignored_lines(the malformed lines, newline-joined, empty when everything parsed).
The detail that trips people
Replacements apply sequentially, top to bottom, and later pairs operate on earlier results. That's a feature when you want chains (A => B, then B => C, so A becomes C) and a gotcha when you expect parallel, independent swaps. If two finds overlap, the second line sees the output of the first. Read your pairs top-down and order them deliberately.
The other quirk: it's a literal, plain-string replace by default - no regex magic. That's on purpose (the pack's Regex String Replace exists for patterns), but it means find is matched as-is. Escape nothing, expect nothing fancy.
Installing it
Standard MoonPack install:
cd ComfyUI/custom_nodes
git clone https://github.com/moonwhaler/comfyui-moonpack.git
or ComfyUI Manager → MoonPack → install, restart. Under MoonPack/string. No models, no third-party Python dependencies.
Verdict
For cleaning up prompts and normalizing text before it hits the encoder, this is a solid, no-frills pick - and ignored_lines is the kind of diagnostic touch that tells you the author actually used these nodes. If your replacements need real pattern matching, reach for Regex String Replace instead; for everything else, this one just works.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Source text. | |
| find_replace_pairs | STRING | find => replace old => new | One pair per line in 'find => replace' format. Empty replacement removes text. |
| whole_word_matchopt | BOOLEAN | false | If true, only complete words match (uses regex \b boundaries). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| ignored_lines | STRING | — |