Nodes/ComfyUI LC123 Nodes/LC Text Replace ✂️
ComfyUI Node

LC Text Replace ✂️

LC Text Replace — a wireable find-and-replace that grows to 20 pairs

By lonecatone23·Created 2 months ago·Updated 3 days ago· 18
LC Text Replace ✂️
    • text
    text
    entrycount1
    use_regexfalse
    count0
    find_1
    replace_1
    find_2
    replace_2
    find_3
    replace_3
    find_4
    replace_4
    find_5
    replace_5
    find_6
    replace_6
    find_7
    replace_7
    find_8
    replace_8
    find_9
    replace_9
    find_10
    replace_10
    find_11
    replace_11
    find_12
    replace_12
    find_13
    replace_13
    find_14
    replace_14
    find_15
    replace_15
    find_16
    replace_16
    find_17
    replace_17
    find_18
    replace_18
    find_19
    replace_19
    find_20
    replace_20

    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_1replace_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.

    CategoryLC123/utils

    Inputs (44)

    NameTypeDefaultDescription
    textSTRINGSource text to transform.
    entrycountINT11–20Number of find/replace pairs to show and apply.
    use_regexBOOLEANfalseTreat find as a regular expression.
    countINT00–99999Max replacements per pair. 0 = replace all.
    find_1optSTRINGFind string #1 (skipped if empty).
    replace_1optSTRINGReplacement for find #1.
    find_2optSTRINGFind string #2 (skipped if empty).
    replace_2optSTRINGReplacement for find #2.
    find_3optSTRINGFind string #3 (skipped if empty).
    replace_3optSTRINGReplacement for find #3.
    find_4optSTRINGFind string #4 (skipped if empty).
    replace_4optSTRINGReplacement for find #4.
    find_5optSTRINGFind string #5 (skipped if empty).
    replace_5optSTRINGReplacement for find #5.
    find_6optSTRINGFind string #6 (skipped if empty).
    replace_6optSTRINGReplacement for find #6.
    find_7optSTRINGFind string #7 (skipped if empty).
    replace_7optSTRINGReplacement for find #7.
    find_8optSTRINGFind string #8 (skipped if empty).
    replace_8optSTRINGReplacement for find #8.
    find_9optSTRINGFind string #9 (skipped if empty).
    replace_9optSTRINGReplacement for find #9.
    find_10optSTRINGFind string #10 (skipped if empty).
    replace_10optSTRINGReplacement for find #10.
    find_11optSTRINGFind string #11 (skipped if empty).
    replace_11optSTRINGReplacement for find #11.
    find_12optSTRINGFind string #12 (skipped if empty).
    replace_12optSTRINGReplacement for find #12.
    find_13optSTRINGFind string #13 (skipped if empty).
    replace_13optSTRINGReplacement for find #13.
    find_14optSTRINGFind string #14 (skipped if empty).
    replace_14optSTRINGReplacement for find #14.
    find_15optSTRINGFind string #15 (skipped if empty).
    replace_15optSTRINGReplacement for find #15.
    find_16optSTRINGFind string #16 (skipped if empty).
    replace_16optSTRINGReplacement for find #16.
    find_17optSTRINGFind string #17 (skipped if empty).
    replace_17optSTRINGReplacement for find #17.
    find_18optSTRINGFind string #18 (skipped if empty).
    replace_18optSTRINGReplacement for find #18.
    find_19optSTRINGFind string #19 (skipped if empty).
    replace_19optSTRINGReplacement for find #19.
    find_20optSTRINGFind string #20 (skipped if empty).
    replace_20optSTRINGReplacement for find #20.

    Outputs (1)

    NameTypeDescription
    textSTRING