Search And Replace
One search term, one replacement, straight text swap
- STRING
The simplest of JNodes' three search-and-replace nodes, and the one to reach for when you've got exactly one thing to swap. The pack's README gives the canonical example: an embedding filename like 3mb3dd1n4 (deliberately obfuscated so it doesn't collide with someone else's file on CivitAI) that you want to actually read as embedding wherever it shows up in a shared or displayed prompt. Feed the prompt text in, tell it what to look for and what to put there instead, get the swapped text back.
It's a building block, not a workflow on its own - you'll usually see it chained after a prompt is assembled and before it's shown, saved, or embedded into an image's metadata, cleaning up exactly the kind of cryptic filenames and trigger words that are meant for the model but ugly for a human to read.
How it works
text is the full string to operate on. search_term is what to find; every occurrence gets replaced, not just the first. replace_with is what goes in its place. It's a literal string match, not a regex - if you need pattern matching or multiple terms replaced in one pass, this specific node isn't built for that (see its list- and file-driven siblings below).
The inputs and outputs
text(STRING, multiline) - the text to search.search_term(STRING) - the exact text to find.replace_with(STRING) - what to replace it with.STRINGoutput - the result.
How to install it
Via ComfyUI Manager: Install Custom Nodes, search "JNodes", install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/JaredTherriault/ComfyUI-JNodes
pip install -r ComfyUI-JNodes/requirements.txt
then restart ComfyUI. No model downloads - plain text processing.
Common issues & troubleshooting
Case sensitivity catching people out. A literal string match means Embedding and embedding are different targets. If your replacement doesn't seem to be firing, check the case matches exactly what's actually in the text, not what you assume is there.
Need to swap more than one term. This node only takes one search_term/replace_with pair. Chaining several of these back to back works fine for two or three swaps, but once you're maintaining a real list of trigger-word substitutions, switch to JNodes_SearchAndReplaceFromList (inline list) or JNodes_SearchAndReplaceFromFile (external file) instead - much less wire-spaghetti for the same result.
Partial-word matches replacing more than intended. Because this is a plain substring match, searching for cat will also hit the cat inside category or concatenate if either happens to appear in your text. If you're seeing unexpected changes elsewhere in the string, that's usually why - pick a search term specific enough not to collide with ordinary words.
Whitespace left behind after a replacement. Swapping a word out for a shorter (or empty) replacement can leave a double space or stray comma. If you're chasing that kind of thing down, JNodes_SplitAndJoin is the pack's own cleanup tool for tidying commas and spacing afterward.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| search_term | STRING | — | |
| replace_with | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |