Nodes/D2 XYPlot Utils/D2 Prompt SR
ComfyUI Node

D2 Prompt SR

D2 Prompt SR does search-and-replace for grids

By da2el-ai·Created 2 years ago·Updated 2 years ago· 5
D2 Prompt SR
    • LIST
    prompt
    search_txt
    replace

    If you've come from Stable Diffusion WebUI, you already know this node - it's the ComfyUI version of A1111's "Prompt S/R" (search and replace) from the X/Y/Z plot script. You hand it one prompt, one search term, and a list of replacements, and it hands back a whole list of prompt variants. That list is what turns a single text box into an XY plot axis.

    First, the honest context, because it changes how you install this: D2 Prompt SR ships in ComfyUI-d2-xyplot-utils by da2el-ai, and that pack has been absorbed into D2 Nodes ComfyUI. The old repo is gone - the README is a single line saying it was integrated, and the successor's own docs tell you to delete ComfyUI-d2-xyplot-utils if you have it installed. The node lives on there as D2 XY Prompt SR, same mechanism, same author. If you're reading this page because you pulled a workflow with a missing "D2 Prompt SR," that's why. Install D2 Nodes and you get the maintained version.

    What it actually does

    Pure string manipulation, nothing clever. You give it:

    • prompt (multiline) - your base prompt, line breaks welcome
    • search_txt (single line) - the text to find. Can be several words, but no newlines
    • replace (multiline) - one replacement per line

    The node splits replace on newlines, swaps search_txt out for each line, and outputs a LIST: the original prompt plus one variant per replacement line. So prompt = "1girl, {STYLE}, detailed face", search_txt = "{STYLE}", and a replace box listing watercolor / oil painting / ink sketch gives you three prompts, ready to feed a grid. Since splitting is by newlines, commas in your replacements are fine - a whole tag chain like watercolor, soft lighting, muted palette counts as one entry.

    That's the whole trick. No regex, no wildcards, no model calls, no API keys. It's a text node.

    Why you'd reach for it

    XY plots live and die on typing the same prompt twelve times with one word changed, which is exactly the error-prone chore this removes. Where the KB's ecosystem docs describe grid workflows as the whole reason people put up with ComfyUI's node graph, D2 Prompt SR is the tool that makes a prompt axis cheap: write one prompt, list the substitutions, and let the plot loop do the rest.

    Install

    Via ComfyUI Manager (search "D2 XYPlot Utils" or just "D2"), or the classic way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/da2el-ai/ComfyUI-d2-xyplot-utils
    

    …then restart ComfyUI. But again: install D2 Nodes ComfyUI instead. Same author, the node is included there as D2 XY Prompt SR with a couple of upgrades (it also emits an x/y_list string you can wire straight into D2 XY Plot, plus the D2 XY Prompt SR2 variant that sits after the plot node and recreates A1111's Prompt S/R flow properly). No model downloads, no pip dependencies beyond what ComfyUI already has - this is about the lightest custom node there is.

    Where people get burned

    • Literal search, not regex. search_txt is a plain str.replace(). If the search string doesn't appear in the prompt, you silently get the original prompt back - no error, just a grid row that doesn't vary.
    • Newlines in search_txt won't work. The original node is single-line search only; the newer D2 XY Prompt SR added newline support on the replace side, not the search side.
    • The successor replaced the old XY Plot. A LIST output was fine when this pack shipped its own plot node, but if you're wiring into a third-party grid workflow, expect to massage the list into newline-separated text - which is precisely why the maintained version added the string output.

    One light aside: for a pack whose whole reason to exist is grids, the "how do I feed the LIST in" question is the recurring one in D2 community threads - the answer is almost always "use D2 XY Prompt SR on the current version and connect x/y_list to D2 XY Plot." If you're stuck on an old workflow, that upgrade is the fix.

    CategoryD2

    Inputs (3)

    NameTypeDefaultDescription
    promptSTRING
    search_txtSTRING
    replaceSTRING

    Outputs (1)

    NameTypeDescription
    LISTLIST