Nodes/ComfyUI Easy Use/easy promptReplace
ComfyUI Node Runs on cloud

easy promptReplace

Find-and-replace for your prompt text

By yolain·Created 3 years ago·Updated 12 days ago· 2,647
easy promptReplace
    • prompt
    prompt
    find1
    replace1
    find2
    replace2
    find3
    replace3

    Sometimes you have one prompt and you want to run it with one word swapped - "red dress" → "blue dress," or a placeholder token replaced by whatever an upstream node produced. easy promptReplace is exactly that: find-and-replace on a prompt string, up to three swaps at once. It's mundane and it's genuinely useful, because it lets you build a prompt template once and vary the interesting part programmatically instead of retyping the whole thing.

    The real power shows up when you stop typing the "find" and "replace" values by hand and start feeding them from other nodes - a wildcard result, a switch, a loop counter formatted to text. Now you've got a prompt that rewrites itself as the graph runs.

    How it works

    You give it a base prompt and up to three find/replace pairs. It walks the prompt string, substitutes each find occurrence with its matching replace, and outputs the rewritten prompt. Straight string substitution - the same operation your text editor does with Ctrl+H, just as a node so it can sit in the middle of a workflow and take its inputs from wires.

    The inputs and outputs that matter

    • prompt - the base text to operate on (multiline).
    • find1 / replace1, find2 / replace2, find3 / replace3 - up to three substitution pairs (all optional). Each find that appears in the prompt gets replaced by its partner. Pairs you leave blank are skipped.
    • prompt (output, STRING) - the rewritten text.

    The output is a string, so - same as every prompt node here - it still needs encoding downstream. A clean pattern is: template phrase with a placeholder like __SUBJECT__ in easy positive, swap the placeholder here, then encode.

    How to install it

    Part of ComfyUI-Easy-Use. ComfyUI Manager: search ComfyUI-Easy-Use, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yolain/ComfyUI-Easy-Use
    

    then install.bat (Windows) or pip install -r ComfyUI-Easy-Use/requirements.txt, and restart. Nothing to download.

    Common issues & troubleshooting

    Nothing gets replaced. The find text has to match what's actually in the prompt - usually this is a case or spacing mismatch. If you're replacing Red but the prompt says red, it won't hit. Match it exactly, or design your templates around unambiguous placeholder tokens (__SUBJECT__, [COLOR]) that can't collide with real words.

    Partial-word surprises. It replaces substrings, so a find of cat will also hit inside category or delicate. Use distinctive placeholder tokens rather than short common words to avoid clobbering something you didn't mean to.

    Order matters with overlapping pairs. If replace1's output contains find2's target, the second pass can act on the first's result. Usually fine, occasionally surprising - if you get a weird cascade, reorder the pairs or make the tokens non-overlapping.

    Still not affecting the image. As with all the prompt-string nodes, the output is text, not conditioning. Make sure the rewritten prompt actually reaches a CLIP encode / loader prompt input, not the sampler directly.

    CategoryEasyUse/Prompt

    Inputs (7)

    NameTypeDefaultDescription
    promptSTRING
    find1optSTRING
    replace1optSTRING
    find2optSTRING
    replace2optSTRING
    find3optSTRING
    replace3optSTRING

    Outputs (1)

    NameTypeDescription
    promptSTRING