D2 XY Prompt SR
Recreate A1111's Prompt S/R in ComfyUI — without the brain damage
- x / y_list
- LIST
If you came over from Automatic1111, you probably remember Prompt S/R - the "find this, replace it with a list of these" trick that makes one workflow generate a whole grid of variations. D2 XY Prompt SR is that feature rebuilt as a ComfyUI node, and it's the node you didn't know you were missing. You type a prompt, tell it what to search for, give it a handful of replacements, and out comes a list you can feed straight into a D2 XY Plot. It's the difference between making five copies of a workflow and making one.
How it works
The mechanism is almost embarrassingly simple, which is why it's so reliable. The search text is replaced in your prompt once per line of the replace box, and each result becomes one entry in the list. The original prompt is included as the first entry - which is the part people forget. If you're comparing hair colors and your replace box has blonde hair, on three lines, you get four plot rows: the original plus one per replacement. So put the "baseline" case at the top of your list, or don't bother listing it separately, because it's coming along whether you like it.
The inputs that matter
You only really touch three things, and two of them are text boxes:
prompt- your base prompt, multiline. Keep it to a single logical line if you can; the node's list output strips line breaks, and multi-line prompts plus multi-line replacements is how grids get confusing.search- the exact text to find. No newlines allowed here.replace- one replacement per line. Commas inside a line are fine, since newlines are the separator.
The outputs are x / y_list, a plain newline-joined string you wire into the x_list (or y_list) of D2 XY Plot / D2 XY Plot Easy, and LIST, the same content as an array for other list-savvy nodes. If you're only doing prompt comparisons, x / y_list is the one that matters.
Installing it
This ships in the D2 Nodes ComfyUI pack, so it comes down in one go:
cd ComfyUI/custom_nodes
git clone https://github.com/da2el-ai/D2-nodes-ComfyUI
…or just search "D2 Nodes ComfyUI" in ComfyUI Manager and hit install. Dependencies are light (piexif and charset-normalizer, both auto-installed), and there are no model files to download. One caveat worth knowing up front: since v32.0.0 the pack requires ComfyUI's newer V3 node schema, so if you're on an old ComfyUI build, pin the pack to a pre-32 release instead of fighting it.
Where people get burned
Two gotchas, both real. First, the replacement is a plain string replace, not a regex - so masterpiece will also match inside masterpiece_best_quality if that's in your prompt. Keep search distinctive. Second, if you run a grid where a prompt row never actually changes anything, the grid just shows identical images and you'll think it's broken. It isn't. Also, if you stop a batch halfway, use the Reset index button on the XY Plot node before rerunning - the plot keeps an internal index across queues, and D2 XY Prompt SR will happily serve up row 9 of a 20-row grid.
The sibling node D2 XY Prompt SR2 does the same replacement after the XY Plot, per-row, which is the better tool when your prompt varies between runs. But for the classic "one prompt, one swap, many variants" workflow, this is the one you reach for.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| search | STRING | — | |
| replace | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| x / y_list | STRING | — |
| LIST | LIST | — |