Nodes/ComfyUI_DD_Nodes/DD Text Replace
ComfyUI Node

DD Text Replace

Find and replace, minus the regex angst

By digital-divas-admin·Created 7 months ago·Updated 5 months ago· 0
DD Text Replace
    • text
    text
    find
    replace_with

    Sometimes a prompt arrives with the wrong word in it, and you'd rather fix the word than rebuild the whole string. DD Text Replace is the plain-language answer: give it text, tell it what to find and what to swap in, and out comes the edited string. No regex, no learning curve - just the same find-and-replace you've used in every text editor since 1995.

    How it works

    Three inputs, all plain strings:

    • text - the source (multiline).
    • find - what to search for.
    • replace_with - what to replace it with.

    Under the hood it's Python's str.replace(), which means a few behaviors you should know before you trust it with a real prompt. It replaces every occurrence, not just the first. It's literal, not regex - "a" finds the letter "a", not "any vowel". And it's case-sensitive: "Portrait" and "portrait" are different strings to it. All of that is predictable once you know it's a plain string swap.

    Where you'll use it

    Prompt cleanup is the obvious job: strip a quality tag you no longer want, swap a character name for a variant, normalize a wildcard-generated prompt before it hits CLIP. It also shines in reusable workflows - keep the prompt logic generic and swap in specifics via find/replace wires instead of editing the text by hand every run. Pair it with DD Text Concatenate for a build-then-clean pipeline, and use DD Show Text to verify the output before encoding.

    The trap that will bite you

    If you leave find empty - which is the default - the behavior is not "nothing happens." Python's str.replace("", X) inserts X between every character: "fox" becomes "fXoXxX". So a forgotten, blank find field silently mangles your text into a near-unreadable mess. It's a cheap mistake to make on a first run and a baffling one to debug, so get into the habit of clearing or filling find deliberately. Also remember the case-sensitivity: "masterpiece" won't touch "Masterpiece".

    Installing it

    Part of the ComfyUI_DD_Nodes pack by Digital Divas. ComfyUI Manager → search "DD Nodes", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/digital-divas-admin/ComfyUI_DD_Nodes.git
    

    Restart ComfyUI. Empty requirements.txt - no extra dependencies, no model downloads. When Manager returns search results, confirm the repo is digital-divas-admin/ComfyUI_DD_Nodes; an unrelated project also goes by "ComfyUI-DD-Nodes."

    CategoryDD Nodes/Text

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    findSTRING
    replace_withSTRING

    Outputs (1)

    NameTypeDescription
    textSTRING