Nodes/ComfyUI-PromptsO/💀Prompts Replace
ComfyUI Node

💀Prompts Replace

Strip, swap, and regex your text before it hits the sampler

By S4MUEL-404·Created 11 months ago·Updated 10 months ago· 3
💀Prompts Replace
    • processed_text
    text
    original_text
    replacement_text
    case_sensitivetrue
    use_regexfalse
    replace_alltrue

    Prompts are a moving target. A prompt written for one checkpoint carries baggage the next one ignores - (word:1.3) weight syntax that LLM-encoded models silently discard, score_9 tags that mean nothing outside the Pony lineage, a shared workflow with someone's private trigger words baked in. 💀Prompts Replace is the node you drop into the middle of the graph to scrub, swap, or strip that text before it reaches a text encoder.

    How it works

    You feed it text, tell it what to find, and what to put in its place. The mechanics are plain Python under the hood - str.replace for the simple path, re.sub when regex is on - but the option set makes it more useful than a glorified editor:

    • original_text - what to search for. Multiline, so multi-token phrases work fine.
    • replacement_text - what to replace it with. Leave this empty to delete the matches entirely, which is the operation you'll actually use most.
    • case_sensitive (on by default) - flip it off and the match becomes case-insensitive.
    • use_regex (off by default) - treat original_text as a regular expression. This is where it gets powerful and where you can hurt yourself; more below.
    • replace_all (on by default) - replace every occurrence instead of just the first.

    Output is a single STRING named processed_text.

    What you'd actually use it for

    The obvious one is stripping weight syntax. If someone hands you an SDXL-era prompt full of ((face:1.4)) and (hands:1.2), and you're targeting an LLM-encoded model where those weights are inert (per the KB's encoder split), you can regex \([^)]*:[0-9.]+\) to nothing and get a clean prompt.

    The less obvious one - and it's a nice loop within this pack - is as the cleanup stage after 💀Prompts from Janus Pro. Janus writes rich natural-language captions; if you want to feed that into a tag-based SDXL model, Replace is where you'd normalize it. Same for the API text nodes: whatever Deepseek or Gemini returns, run it through here to strip boilerplate or swap model-specific tokens.

    The gotchas

    Two things to keep in mind, both grounded in the code. First, regex mode passes your original_text straight to re.sub - a malformed pattern raises a clear "Regular expression error" and the node won't run. Escape literal characters you don't mean as syntax (dots, parens, brackets). Second, the node logs the match count to the console, so when your replacement "did nothing," check that log - the pattern matched zero times, not the node failing.

    Also note the node refuses to run if either the input or the search text is empty, which is just sensible validation, not a bug.

    Install

    It's part of the pack, one install covers all of it:

    # ComfyUI Manager: search "PromptsO", install, restart.
    
    cd ComfyUI/custom_nodes
    git clone https://github.com/S4MUEL-404/ComfyUI-PromptsO.git
    pip install -r ComfyUI-PromptsO/requirements.txt
    

    Look for it under 💀PromptsO. It's a small node with a small job, but prompt hygiene is one of those things that separates "works on my machine" workflows from ones that survive contact with someone else's checkpoint.

    Category💀PromptsO

    Inputs (6)

    NameTypeDefaultDescription
    textSTRINGInput text to process
    original_textSTRINGText to find and replace
    replacement_textSTRINGReplacement text (empty to remove)
    case_sensitiveoptBOOLEANtrueWhether the search should be case sensitive
    use_regexoptBOOLEANfalseUse regular expressions for pattern matching
    replace_alloptBOOLEANtrueReplace all occurrences (vs. only first occurrence)

    Outputs (1)

    NameTypeDescription
    processed_textSTRING