YC text replace
Find-and-replace for your prompt, up to three swaps deep — dead simple, occasionally perfect
- prompt
Feed it a prompt, give it up to three find/replace pairs, get the edited prompt back. It's Python's str.replace with a face - the whole implementation is three sequential .replace() calls. There's no regex, no wildcards, no case-insensitive magic. That's the whole node, and honestly that's most of what you need from a prompt-editing utility.
What it's actually for
Prompt reuse and programmatic swaps. You keep one template prompt and swap tokens per run: swap the subject, swap the style keyword, swap a quality tag. Or you're piping prompts in from a file/CSV and need to normalize them before they hit the CLIP encoder - strip a tag, replace a phrase that breaks your model, rename a trigger word. Anywhere you'd reach for find-and-replace in a text editor, this node does it inside the graph, live, per run.
How it works
Sequential replacement, in order: find1 → replace1, then find2 → replace2, then find3 → replace3. Because they run in sequence, you can do staged edits - replace one phrase, then operate on the result. Empty find fields are skipped cleanly (.replace("", ...) is a no-op in this setup since the node guards them with defaults). The replacements are case-sensitive and literal: "cat" will not match "Cat", and "cat" will match the "cat" inside "concatenate" - substring replacement, not whole-word.
Inputs and outputs
The inputs you'll actually set:
- prompt - the text to edit (multiline)
- find1 / replace1 - first swap
- find2 / replace2 - second swap
- find3 / replace3 - third swap
Output is the edited prompt string, ready to wire into a CLIP Text Encode or a text display.
Install
Part of ComfyUI-YCNodes. ComfyUI Manager → search "ComfyUI-YCNodes" → install, restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI-YCNodes
Deps are the pack standard (torch, numpy, pillow, opencv-python, scipy), no model files.
Where people get burned
- Substring, not word.
"an"→"a"will happily rewrite "another" into "aother". Watch for short, common find strings; the node does exactly what you said, not what you meant. - Case-sensitive only. There's no ignore-case toggle. If your template mixes capitalization, you'll need exact-case matches or multiple pairs.
- Three pairs max. More complex rewrites need a regex node or a Python-based text utility. This one is intentionally dumb.
It's the node equivalent of a pocket knife: unglamorous, limited, and exactly right when the job is "swap a few tokens in this prompt before it goes to the encoder."
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| find1opt | STRING | — | |
| replace1opt | STRING | — | |
| find2opt | STRING | — | |
| replace2opt | STRING | — | |
| find3opt | STRING | — | |
| replace3opt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |