abaf2a0bf78aaceb1bd4f34b9c28d89cdbf9a0fd
ComfyUI Multi-Replace
A ComfyUI custom node package for creating and applying multiple find/replace pairs to text.
Features
-
Find/Replace Pairs Node: Create an arbitrary number of find/replace pairs
- Starts with one pair, click "➕ Add Pair" button to add more
- Right-click menu also provides Add/Remove pair options
- All pairs are input connectors for easy connection from other nodes
- Outputs: pairs object, JSON, and CSV formats
-
Text Replacer Node: Apply find/replace pairs to text
- Accepts pairs from the FindReplacePairs node
- Supports regular expressions
- Case-sensitive/insensitive matching
- Replace all or first occurrence only
- Outputs: modified text, pairs passthrough (for chaining), changes log, and replacement count
Installation
-
Clone or copy this folder to your ComfyUI
custom_nodesdirectory:cd ComfyUI/custom_nodes git clone <repo-url> comfyui-multi-replace -
Restart ComfyUI
Usage
Basic Usage
- Add a Find/Replace Pairs node
- Enter your find pattern and replacement in the first pair
- Click ➕ Add Pair to add more pairs as needed
- Connect the
pairsoutput to a Text Replacer node - Enter or connect your input text
- Get the modified text from the
resultoutput
Connecting Dynamic Values
All find/replace pairs are input connectors, making it easy to connect values from other nodes (e.g., text prompts, primitives, or other string outputs).
Chaining Replacers
The Text Replacer node passes through the pairs object, allowing you to chain multiple replacers or use the same pairs set multiple times.
Output Formats
Find/Replace Pairs outputs:
pairs- Internal pairs object for use with TextReplacerjson_output- JSON array of pairs:[{"find": "...", "replace": "...", "index": 1}, ...]csv_output- CSV format:find,replaceper line
Text Replacer outputs:
result- The text after all replacementspairs_passthrough- The pairs object (for chaining)changes_log- Human-readable log of changes madereplacement_count- Total number of replacements performed
Node Reference
Find/Replace Pairs
| Input | Type | Description |
|---|---|---|
find_N |
STRING (connector) | Find pattern for pair N |
replace_N |
STRING (connector) | Replacement for pair N |
Buttons:
- ➕ Add Pair - Add a new find/replace pair
- ➖ Remove Last Pair - Remove the last pair (disabled when only 1 pair exists)
Text Replacer
| Input | Type | Description |
|---|---|---|
pairs |
FR_PAIRS | Pairs from FindReplacePairs node |
input_text |
STRING | Text to perform replacements on |
input_text_connected |
STRING (connector) | Optional connected text input |
use_regex |
BOOLEAN | Treat patterns as regex |
case_sensitive |
BOOLEAN | Case-sensitive matching |
replace_all |
BOOLEAN | Replace all vs first occurrence |
License
MIT License
Languages
Python
65.3%
JavaScript
34.7%