简易文本替换🐠meeeyo.com
The boring find-and-replace node you'll reach for constantly
- STRING
Some nodes are clever and some are just useful, and SimpleTextReplacer is firmly in the second camp. It does one thing: swap every occurrence of one string for another. That's Python's str.replace() exposed as a node, with a \n escape for newlines thrown in. It's the node you reach for when a prompt has the wrong model name in it, when a tag needs normalizing, or when you need to swap , for | so another node in this pack will parse it.
The Chinese display name is 简易文本替换 ("simple text replace"). It's part of ComfyUI_StringOps, and it's the plainest member of the pack's replace family: SimpleTextReplacer (all), ReplaceNthOccurrence (one position), ReplaceMultiple (a sequence of values).
How it works
Three inputs:
- input_string - the text to process. It's marked
forceInput, so you can wire a string in from another node instead of typing, though typing works fine too. - find_text - what to look for. If it's empty, the node returns your input unchanged (no error - useful, but easy to trip over).
- replace_text - what to replace it with. Type
\nto insert an actual newline.
Output: one STRING with every occurrence of find_text replaced by replace_text. It's literal text matching - no regex, no case-insensitivity - so cat will not match Cat. If you need patterns, this isn't the node (the pack doesn't ship a regex replacer either; that's a bigger-pack job).
Where you'd use it
- Prompt normalization: swap a model's full name for its short form, or vice versa.
- Format bridging: turn commas into pipes (
find_text = ",",replace_text = "|") soNumberExtractororReadExcelData-style consumers can parse the result. - Cleaning: strip a repeated phrase, replace a placeholder token with a real value.
- Newline insertion: replace a delimiter with
\nto build a multiline list forTextToList.
It chains well with the rest of the pack - feed it the output of ReadExcelData and normalize before parsing, or feed its output into TextToList to get a clean list.
The traps
There are two, and both are silent. First, empty find_text returns the input unchanged - no error, so a forgotten field just means "nothing happened." Second, the replace is case-sensitive and literal: Replace won't touch replace. And unlike ReplaceNthOccurrence, there's no "first occurrence only" mode - this is all-or-nothing by design.
Installing it
Pack standard: ComfyUI Manager → ComfyUI_StringOps, or
cd ComfyUI/custom_nodes
git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git
Restart. No dependencies beyond ComfyUI's own Python.
The honest take
This is the workhorse of the pack - nothing about it is exciting, but it's the one you'll actually use, because string cleanup is the unglamorous 80% of prompt engineering. If you install ComfyUI_StringOps for a single node, this (or TextToList) is probably it. Just remember it's literal and all-occurrences, and you'll never be surprised.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_string | STRING | — | |
| find_text | STRING | — | |
| replace_text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |