D2 XY Prompt SR2
A1111's Prompt S/R, as a node that sits inside the XY loop
- STRING
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 toSTRINGand list your replacement values inx_list. - Wire the plot's
x_other(ory_other) into this node'sx_y. - Set
searchto the placeholder in your prompt - e.g. searchcharacterin "1girl, character, detailed" and listblonde,brunette,silveras your axis values. - Feed this node's
STRINGoutput 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-ComfyUIand 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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| search | STRING | — | |
| prompt | STRING | — | |
| x_y | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |