Stable Diffusion Wildcards with Dynamic Prompts
- Editorial status
- Verified
- Last verified
- 2026-07-16
- Sources
- 5 listed
On this page
Key takeaways
- Pick the smallest construct that fits
- Variant syntax: `{a|b}`
- Wildcard files: `__name__`
- Deterministic folder-resolution example
Stable Diffusion Wildcards with Dynamic Prompts
Dynamic Prompts expands a text template before the resulting prompt reaches Stable Diffusion. Its variant syntax handles short choices inline, while wildcard files keep larger or reusable choice lists outside the prompt.
Version boundary: Dynamic Prompts upstream main commit de056ff8d80e4ad120e13a90cf200f3383f427c6, documented against AUTOMATIC1111 1.10.1. Documentation verified: 2026-07-16.
No independent image-generation comparison was performed for this guide.
Pick the smallest construct that fits
| Requirement | Construct | Text form | Expansion effect |
|---|---|---|---|
| A few visible alternatives | Variant | `{fog | rain |
| A reusable list | Text wildcard | __weather__ backed by weather.txt | Selects one line from the file |
| A categorized collection | Nested path | __places/coast__ | Resolves a file inside a folder hierarchy |
| Unequal selection frequency | Weighted variant | `{3::fog | 1::rain}` |
| Every cross-product prompt | Combinatorial sampler | Two or more variants or wildcards | Enumerates the available combinations |
Use ordinary variants while the alternatives still fit comfortably in the prompt. Move a list to a wildcard file when it needs reuse, review, or a directory structure.
Variant syntax: {a|b}
Wrap choices in braces and separate them with |:
a {foggy|rainy|snowy} station platform
This template has three possible text expansions. A second independent variant multiplies the count:
a {foggy|rainy|snowy} station platform at {dawn|night}
The expansion space is 3 weather choices x 2 time choices = 6 prompts. Random sampling may repeat a choice before every possible prompt appears; combinatorial sampling requests the cross-product instead.
Wildcard files: __name__
The extension's tutorial records the default folder as:
extensions/sd-dynamic-prompts/wildcards
Create a plain text file with one value per line:
# wildcards/materials.txt
brick
weathered wood
painted steel
Reference the filename without .txt, surrounded by double underscores:
a small workshop built from __materials__
Lines beginning with # are comments. A basic text wildcard uses one entry per line; use the documented YAML or JSON formats when a structured hierarchy or multiline values are required.
Deterministic folder-resolution example
This file tree makes the name-to-file mapping explicit:
wildcards/
places/
coast.txt
forest.txt
weather.txt
# places/coast.txt
shingle beach
tidal flat
rocky cove
The prompt token __places/coast__ resolves to wildcards/places/coast.txt; __places/forest__ resolves to the sibling file. The path resolution is deterministic, but selection among a file's lines follows the active sampler.
The syntax documentation also supports glob patterns. For example, __places/*__ can draw from matching files in places, while a recursive ** pattern can include deeper descendants. Start with an exact nested path so a folder or spelling error remains visible.
Weighted choices
Place a relative weight and :: before an option:
an exterior in {3::overcast light|1::hard sunlight}
Weights are relative and do not need to sum to one. An omitted weight counts as one. A 3 versus 1 relationship changes sampling frequency; it does not create a probability claim about a small batch and does not guarantee a particular sequence.
Standard text wildcard files do not attach weights directly to individual lines. The documented YAML form can contain weighted variant syntax when weighted reusable data is needed.
Reproducible text-only expansion worksheet
Create these two files:
# weather.txt
fog
rain
# places/coast.txt
tidal flat
rocky cove
shingle beach
Then use:
a {wide|close} view of a __places/coast__ in __weather__
| Input | Count |
|---|---|
| View variant | 2 |
| Coast wildcard | 3 |
| Weather wildcard | 2 |
| Total cross-product | 2 x 3 x 2 = 12 |
Combinatorial mode has twelve prompt expansions for this worksheet. Image-generation work can be larger than the text count: batch settings, repeated seeds, high-resolution passes, or other scripts can add work. Calculate the prompt cross-product before enabling a combinatorial run.
Syntax and failure table
| Symptom | Likely text-level cause | Single check |
|---|---|---|
| Braces remain in the submitted prompt | Dynamic Prompts is disabled or the braces are malformed | Try `{red |
__name__ remains unresolved | File name, folder path, or delimiter is wrong | Try an exact root-level wildcard |
| A nested wildcard is empty | The referenced file has no selectable lines | Remove comments and blank lines from a temporary copy |
| Weighted output appears uniform in a small batch | The batch is too small to describe relative frequency | Inspect template syntax without drawing a distribution conclusion |
| The run expands far beyond the worksheet | A wildcard contains nested variants or combinatorial mode is active | Replace that wildcard with one literal value |
| The same logical value changes when reused | The wildcard is evaluated at each occurrence | Use the documented variable syntax when one sampled value must be reused |
One-variable debugging sequence
Hold the seed and unrelated WebUI settings fixed, then change only one item per step:
- Extension state: replace the full template with
{red|blue}and confirm expansion is enabled. - Root file: create
probe.txtcontaining a single literal line and call__probe__. - Path: move that same file into one folder and change only the token to
__folder/probe__. - Cardinality: add one line to the file; do not add variants yet.
- Variant: add one inline
{a|b}choice while retaining the single wildcard. - Weight: add relative weights to that inline choice only.
- Sampler: switch from random to combinatorial only after the arithmetic matches the files.
This order separates extension loading, delimiter syntax, file discovery, folder resolution, list size, weighting, and sampling mode. It does not test image quality or model adherence.
Boundaries and related references
Dynamic Prompts changes text selection; it does not assign text to canvas areas. Use the Regional Prompter reference when each clause needs a spatial region.
Review repository provenance and rollback steps in the extension selection and installation guide. Keep exclusions bounded with the Stable Diffusion negative prompts reference instead of multiplying a long unreviewed negative prompt through every template.
Primary sources
Try the Visual Prompt Generator
Build Midjourney, DALL-E, and Stable Diffusion prompts without memorizing parameters.
Go →See more AI prompt guides
Explore more AI art prompt tutorials and walkthroughs.
Go →Ready to create your own prompts?
Try our visual prompt generator - no memorization needed!
Try Prompt Generator