Nodes/ComfyUI-DynPromptSimplified/DynPrompt Expand (deep-mirrored)
ComfyUI Node

DynPrompt Expand (deep-mirrored)

The wildcard node that writes your negative prompt for you

By RegulusAlpha·Created about a year ago·Updated 10 months ago· 5
DynPrompt Expand (deep-mirrored)
    • text
    • negative
    text
    negative
    seed0
    variety0
    wildcard_dir
    auto_neg_from_mirtrue

    If you've ever run a wildcard workflow, the first half of this node is nothing new: {red|blue|green} picks a random branch, __color__ pulls a random line out of a text file, and the same seed gives you the same "random" pick every time. That part is table stakes. What makes DynPrompt Expand (deep-mirrored) worth a look is the second half of its name - it's the rare wildcard node that also keeps your negative prompt from contradicting what your positive just rolled.

    The bracket trick and __wildcards__ are old A1111 vocabulary that most people who picked ComfyUI up after 2024 never learned, and they're still the cheapest way to batch out variety: same character, different hair, outfits, lighting, no training involved. The classic trap is what your negative does while that's happening. You write lowres, bad anatomy in your negative and forget about it, then __hats__ picks "top hat" and your negative still says hat somewhere - you've asked CFG to push toward and away from the same token at once. This node's whole party trick is solving that.

    How it works

    Drop a file called hats-mir.txt next to your other wildcards and call __hats-mir__ in your positive prompt. The positive side picks one option; the negative side gets all the other options, comma-separated. Pick red hat for positive, and the negative automatically becomes blue hat, green hat. The negative is an inverse of the pick, deterministically, per seed - not a second independent roll that might ban the thing you just chose.

    The clever bit is auto_neg_from_mir (default ON). It scans your positive for any __*-mir__ token - even one nested inside another wildcard file - and injects the complement into the negative without you writing it there at all. So you can leave your negative prompt blank and still get proper exclusions. Resolution is strict: __hats-mir__ reads only hats-mir.txt, never falling back to hats.txt.

    Under the hood, expansion runs braces → wildcards → braces, and each decision point hashes (seed, counter, token name, variety) to pick an index. Fixed words and commas don't advance the counters, so editing fixed text doesn't reshuffle your picks - only adding or removing a {…} or a __wildcard__ changes the draw sequence. That was a deliberate fix (the changelog calls out prompts "converging" because static text was influencing the RNG). The variety input is an integer salt: bump it 0→1 with the same seed and you get a different, still-reproducible lane.

    Inputs and outputs that matter

    • text and negative - your two prompt boxes. These are the whole job.
    • seed - decides every pick. Feed it the same seed your sampler uses so renders reproduce.
    • variety - the extra-randomness lane (0–100, 0 = off). Sweep it to explore variants without touching your seed.
    • wildcard_dir - folder for your .txt files; supports subfolders like clothes/tops.txt. Defaults to the pack's wildcards/ folder.
    • auto_neg_from_mir - the auto-mirror switch. Leave it on.

    Outputs are two strings, text and negative, which wire straight into your usual positive and negative CLIP Text Encode nodes.

    Installing it

    ComfyUI Manager: search for the pack title, "ComfyUI Dynamic Prompting Simplified", hit install, restart. Or do it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/RegulusAlpha/ComfyUI-DynPromptSimplified
    

    Restart ComfyUI and add the node from Add Node → prompt → DSynPrompt Expand (deep-mirrored). There are no dependencies, no model downloads, no API keys - it's pure stdlib Python. Just drop your wildcard .txt files into the wildcards/ folder (one option per line; lines may themselves contain braces and further wildcard calls), or point wildcard_dir anywhere else. License is GPLv3, same as the dynamic-prompting lineage it descends from.

    Where people get burned

    • Typos are silent. A missing wildcard file expands to an empty string and the token just vanishes, so your prompt quietly changes and you can't see why. Preview the output before batch-rendering (the README points at a "preview any" node).
    • Mirrors are a CFG-era trick. On guidance-distilled models - Flux dev/schnell, Turbo/Lightning, Z-Image Turbo at their designed CFG of 1 - the negative prompt does nothing at all, because CFG 1 skips the unconditioned pass entirely. The deep-mirror feature buys you nothing there. For SD 1.5 / SDXL / Illustrious-style workflows, it's genuinely useful.
    • Changing a decision point reshuffles everything downstream. That's by design, not a bug - add one {…} and the whole draw sequence shifts.

    Nested braces, empty branches ({option|}), recursion caps against runaway expansion, and path traversal blocking are all handled. It's a small pack with one good idea, and it executes that idea properly.

    Categoryprompt

    Inputs (6)

    NameTypeDefaultDescription
    textSTRING
    negativeSTRING
    seedINT00–2147483647
    varietyINT00–100Extra randomness lane. 0 = off; same seed+variety reproduce.
    wildcard_dirSTRINGFolder with wildcard .txt files (supports subfolders like clothes/tops.txt)
    auto_neg_from_mirBOOLEANtrueAppend deep mirrored exclusions for any __*-mir__ found in Positive (strict lookup).

    Outputs (2)

    NameTypeDescription
    textSTRING
    negativeSTRING