LC Text Replace ✂️
LC Text Replace — a wireable find-and-replace that grows to 20 pairs
- text
LC Text Replace is the find-and-replace node that works on wires, not just text boxes. Text in one side, up to twenty find/replace pairs applied in order, clean text out the other. It's from the LC123 utility family and it exists because in ComfyUI, prompts are data - and data wants to be transformed, not retyped.
The practical win is cleaning up other nodes' output. A wildcard spits out a line you want to retune; a tagger returns masterpiece when your model doesn't want it; a shared prompt has a style token you need to swap for your own. Slap a replace between the source and the CLIP encoder and you've edited the stream without touching the thing that produced it. You also get regex, so one node can normalize whole classes of junk rather than one literal string.
How it works
One text input (wire-only), then find_N / replace_N pairs up to twenty deep, plus three controls:
- entrycount (1–20) - how many find/replace rows are shown and applied. Raise it to add rows, lower it to remove them. This is the "grows with your needs" part - you start at 1 and only expand when you actually have more cleanup to do.
- use_regex - treat finds as regular expressions. This is where it gets powerful: a find of
\(.*?\)with an empty replace deletes every weighted tag, or^.*?,strips everything up to the first comma. Invalid regexes are skipped silently - which is kind, but also means a typo does nothing, so sanity-check your output. - count - max replacements per pair;
0(default) means replace all matches.
Empty find entries are skipped, so unused rows can't corrupt anything. Pairs apply sequentially, each operating on the previous result - so find_1 → replace_1 happens before find_2 runs. That ordering is your main mental model: if pair 1 rewrites a string that pair 2 was looking for, pair 2 never sees it.
Output is a single text string, ready for CLIP Text Encode, the Prompt Assembler, or further string nodes.
The gotchas worth knowing
Sequential ordering cuts both ways. Use it deliberately: first normalize ("1girl" → "one girl"), then swap tokens, then strip leftovers. But don't expect pair independence - overlapping finds will interact, and the earlier pair wins.
Regex is greedy by default. .* will eat as much as it can, which is often not what you meant in a prompt context. If a replacement looks like it swallowed too much, reach for a non-greedy .*? or anchor it. And remember the plain-string default is fine for 90% of jobs - regex is a lever, not a requirement.
One more: there's a sibling, LC Text Remove, for pure deletion, and it adds whitespace-collapsing that this node doesn't. If you're removing a bunch of tokens and the prompt comes out with double spaces, that's expected behavior here - LC Text Remove handles that case more gracefully.
Install
Part of lonecatone23's ComfyUI_LC123_nodes pack, installable the standard two ways:
- ComfyUI Manager - search "LC123" or "ComfyUI_LC123_nodes", install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/lonecatone23/ComfyUI_LC123_nodes, restart.
No extra pip packages - the pack runs on ComfyUI's own environment (torch + numpy) and ships no requirements.txt, so you don't get dependency roulette.
Verdict
If you've never fed a node into another node, this looks like a word-processor feature wearing a graph costume. Then you hit your first "the tagger keeps adding X" workflow and it becomes a permanent fixture. For literal find/replace on prompt data, it's about as simple and robust as it gets.
Inputs (44)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Source text to transform. | |
| entrycount | INT | 11–20 | Number of find/replace pairs to show and apply. |
| use_regex | BOOLEAN | false | Treat find as a regular expression. |
| count | INT | 00–99999 | Max replacements per pair. 0 = replace all. |
| find_1opt | STRING | Find string #1 (skipped if empty). | |
| replace_1opt | STRING | Replacement for find #1. | |
| find_2opt | STRING | Find string #2 (skipped if empty). | |
| replace_2opt | STRING | Replacement for find #2. | |
| find_3opt | STRING | Find string #3 (skipped if empty). | |
| replace_3opt | STRING | Replacement for find #3. | |
| find_4opt | STRING | Find string #4 (skipped if empty). | |
| replace_4opt | STRING | Replacement for find #4. | |
| find_5opt | STRING | Find string #5 (skipped if empty). | |
| replace_5opt | STRING | Replacement for find #5. | |
| find_6opt | STRING | Find string #6 (skipped if empty). | |
| replace_6opt | STRING | Replacement for find #6. | |
| find_7opt | STRING | Find string #7 (skipped if empty). | |
| replace_7opt | STRING | Replacement for find #7. | |
| find_8opt | STRING | Find string #8 (skipped if empty). | |
| replace_8opt | STRING | Replacement for find #8. | |
| find_9opt | STRING | Find string #9 (skipped if empty). | |
| replace_9opt | STRING | Replacement for find #9. | |
| find_10opt | STRING | Find string #10 (skipped if empty). | |
| replace_10opt | STRING | Replacement for find #10. | |
| find_11opt | STRING | Find string #11 (skipped if empty). | |
| replace_11opt | STRING | Replacement for find #11. | |
| find_12opt | STRING | Find string #12 (skipped if empty). | |
| replace_12opt | STRING | Replacement for find #12. | |
| find_13opt | STRING | Find string #13 (skipped if empty). | |
| replace_13opt | STRING | Replacement for find #13. | |
| find_14opt | STRING | Find string #14 (skipped if empty). | |
| replace_14opt | STRING | Replacement for find #14. | |
| find_15opt | STRING | Find string #15 (skipped if empty). | |
| replace_15opt | STRING | Replacement for find #15. | |
| find_16opt | STRING | Find string #16 (skipped if empty). | |
| replace_16opt | STRING | Replacement for find #16. | |
| find_17opt | STRING | Find string #17 (skipped if empty). | |
| replace_17opt | STRING | Replacement for find #17. | |
| find_18opt | STRING | Find string #18 (skipped if empty). | |
| replace_18opt | STRING | Replacement for find #18. | |
| find_19opt | STRING | Find string #19 (skipped if empty). | |
| replace_19opt | STRING | Replacement for find #19. | |
| find_20opt | STRING | Find string #20 (skipped if empty). | |
| replace_20opt | STRING | Replacement for find #20. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |