TT_TextReplacer
Find and replace for your prompt, the honest version
- output_text
Every prompt needs a find-and-replace eventually. You're iterating on a character, you keep writing the wrong name, or you've decided masterpiece, best quality is coming out of all your prompts. TT_TextReplacer is the pack's answer: feed it a string, tell it what to find and what to swap in, get the edited string back. The README's summary is one sentence - "replaces a word or a phrase with another" - and the node is exactly that honest.
How it works. The mechanism is a single Python str.replace(find_word, replace_word) call on the input text. That one line tells you everything that matters:
- It replaces every occurrence, not just the first. Find
redand everyredin the string becomes your replacement. - It's case-sensitive.
redwon't touchRedorRED. - It's literal text, not regex. No patterns, no wildcards, no capture groups.
The inputs: input_text_1 (multi-line, the text to edit), find_word and replace_word (both single-line). Output is output_text, a STRING - wire a previous prompt or text node into the input, then feed the output into a CLIP Text Encode or wherever the string needs to go.
Where it fits in a workflow. This is a utility in the middle of a chain, not a source: a TT_TextInput or TT_StoryCombiner output flows in, TT_TextReplacer edits it, the edited prompt flows on. Two genuinely handy patterns: global cleanup (strip a quality tag or negative boilerplate from every prompt in one place) and character/entity swapping (rename a subject across a long generated prompt without retyping it). The case-sensitivity is worth leaning into - it's a feature when you want to fix cat without touching caterpillar in a phrase like "a cat and her caterpillar."
Where people get burned. The global-replace behavior is the surprise that bites: most people expect the first match only, and this does all of them. If you need one-off replacement, put your find phrase somewhere the rest of the string doesn't contain. And the literal-text limit is real - the day you need foo\s+\w+ or a case-insensitive swap, this isn't the tool; a bigger text-toolkit pack (WAS Node Suite and friends) does regex properly. It also can't chain multiple find/replace pairs in one pass - two swaps means two nodes, or do the second replace on the first node's output.
Install. Same as the rest of the pack, one install gets all four nodes: ComfyUI Manager → search "TT_TextTools" → install, restart; or git clone https://github.com/zzubnik/TT_TextTools into ComfyUI/custom_nodes and restart. No dependencies, no models. It's a small, dumb, reliable tool - for simple prompt surgery it beats building the same thing with a script node, and it never touches your source text.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_text_1 | STRING | — | |
| find_word | STRING | — | |
| replace_word | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output_text | STRING | — |