Nodes/Comfyui-TOO-Pack/TOO Much Replace πŸ”„
ComfyUI Node

TOO Much Replace πŸ”„

Five rules of cleanup for prompts and strings

By tetsuoo-onlineΒ·Created 9 months agoΒ·Updated about a month agoΒ· 5
TOO Much Replace πŸ”„
    • STRING
    β—„stringβ–Ί
    β—„input_1β–Ί
    β—„output_1β–Ί
    β—„input_2β–Ί
    β—„output_2β–Ί
    β—„input_3β–Ί
    β—„output_3β–Ί
    β—„input_4β–Ί
    β—„output_4β–Ί
    β—„input_5β–Ί
    β—„output_5β–Ί

    TOO Much Replace is a string cleaner: one input, up to five find-and-replace rules, one output. You drop a string in, tell it what to strip or rewrite, and it applies the rules in order. The name oversells it - it's five rules, not a hurricane - but five is exactly the right number for the job it's actually good at: scrubbing prompts and text before they go into a filename or metadata.

    That's the real use case, and it pairs perfectly with this pack's saver. Grab your positive prompt with Extract Widget From Node, run it through Too Much Replace to delete the garbage tokens, then feed the result into the saver's naming. The classic move: in: (masterpiece, best quality) β†’ out: (empty), which turns a filename like beautiful_landscape_(masterpiece,_best_quality).webp into beautiful_landscape.webp. Same trick for removing weight syntax, stripping duplicate tags, or rewriting a word you keep mistyping.

    How it works. Each rule is a pair - input_N is the search text, output_N is the replacement. Rules run in sequence on the result of the previous one, and only rules with a non-empty search string do anything. Two important details. First, it's a literal search-and-replace (str.replace), not regex - so (masterpiece) means exactly that text with the parens. If you need regex, the pack's Preset Text node has regex-flavored presets instead. Second, the node declares IS_CHANGED so it always re-runs, which matters because it's often fed by live values (widget extraction) that the cache would otherwise miss. The trade-off: it keeps everything downstream of it dirty, so don't put it in front of a heavy sampler.

    Inputs and outputs. Required: string (the multiline input) and five rule pairs - input_1/output_1 through input_5/output_5. Output is a single STRING. Leave unused rules empty; they're skipped.

    Install.

    cd ComfyUI/custom_nodes
    git clone https://github.com/tetsuoo-online/Comfyui-TOO-Pack
    

    or ComfyUI Manager β†’ "Comfyui-TOO-Pack" β†’ restart. No dependencies.

    Where people get burned. Because rules apply in order, a later rule can undo an earlier one - if rule 1 turns masterpiece into art, and rule 2 removes the word art, you've removed your own fix. Order matters, top-down. And don't expect regex: paste \d+ and it will literally search for the characters backslash-d-plus, find nothing, and silently do nothing. For a cleanup step in a filename pipeline it's dependable and fast; just know its limits before you ask it for magic.

    CategoryπŸ”΅TOO-Pack/utils

    Inputs (11)

    NameTypeDefaultDescription
    stringSTRINGInput string to process
    input_1STRINGPattern to search for (rule 1)
    output_1STRINGReplacement value (rule 1)
    input_2STRINGPattern to search for (rule 2)
    output_2STRINGReplacement value (rule 2)
    input_3STRINGPattern to search for (rule 3)
    output_3STRINGReplacement value (rule 3)
    input_4STRINGPattern to search for (rule 4)
    output_4STRINGReplacement value (rule 4)
    input_5STRINGPattern to search for (rule 5)
    output_5STRINGReplacement value (rule 5)

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGβ€”