Nodes/D2 Nodes ComfyUI/D2 XY Prompt SR2
ComfyUI Node

D2 XY Prompt SR2

A1111's Prompt S/R, as a node that sits inside the XY loop

By da2el-ai·Created 2 years ago·Updated 3 days ago· 66
D2 XY Prompt SR2
    • STRING
    search
    prompt
    x_y

    Stable Diffusion webui users coming to ComfyUI often ask "where's Prompt S/R?" - the feature that swaps one word in a prompt for a list of alternatives across a grid. D2 XY Prompt SR2 is that feature as a node, and the "2" in the name tells you where it sits: after the XY plot, inside the loop, rewriting the prompt on every cell.

    The setup is clean: your XY plot varies something as STRING, its current value comes out of the plot (via x_other or y_other), and this node plugs that value into your prompt before it reaches the encoder. Same mechanic as A1111's S/R, one search term, many replacements - except here the "many" is just the plot's axis list.

    The inputs and outputs

    • search - the text to find in the prompt. Can be multiple words, but not a newline.
    • prompt - the target prompt that gets modified.
    • x_y - the replacement text, wired from the XY plot's current value.

    Output: a single STRING - your prompt with every occurrence of search replaced by x_y. It's a straight prompt.replace(search, x_y), no regex, all occurrences replaced.

    How to use it

    • On your D2 XY Plot (or Easy/Mini), set the axis type to STRING and list your replacement values in x_list.
    • Wire the plot's x_other (or y_other) into this node's x_y.
    • Set search to the placeholder in your prompt - e.g. search character in "1girl, character, detailed" and list blonde, brunette, silver as your axis values.
    • Feed this node's STRING output into the prompt encoder instead of your static prompt.

    There's also a sibling, D2 XY Prompt SR (no "2"), which does the same replace but before the plot - it produces the full list for the x_list field. SR2 is the one you want when you're already inside the loop, and it composes with any plot node, not just D2's.

    Installing

    Part of the D2-nodes-ComfyUI pack - install the pack, not the node.

    • ComfyUI Manager → search "D2-nodes-ComfyUI" → Install → restart.
    • Or cd ComfyUI/custom_nodes && git clone https://github.com/da2el-ai/D2-nodes-ComfyUI and restart.

    Dependencies: piexif, charset-normalizer - nothing heavy, no model downloads. Pack gotcha: v32.0.0+ requires the newer ComfyUI V3 schema; older ComfyUI → pre-32.0.0 release.

    Where people get burned

    replace is case-sensitive and literal. If your prompt has both character and Character, only the exact case matches. And there's no escaping - if search appears inside another word, it gets replaced there too, so pick a search term that's distinctive (a short placeholder like __x__ is a solid habit). Finally, remember this only modifies the string; the type of your plot axis still needs to be STRING, or the value arriving at x_y won't be text at all.

    CategoryD2/XY Plot

    Inputs (3)

    NameTypeDefaultDescription
    searchSTRING
    promptSTRING
    x_ySTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING