ComfyUI Node

Wildcard Prompt

Your prompts, but randomized on purpose — Wildcard Prompt without the bloat

By vpominchuk·Created 6 months ago·Updated 6 months ago· 0
Wildcard Prompt
    • STRING
    • USED_SEED
    prompt
    seed0
    wildcard_path
    string_in

    The one-trick node you'll actually keep

    This is the A1111 wildcard idea - __token__ in a prompt that gets swapped for a random line from a text file - distilled into a single ComfyUI node with zero dependencies. If you've ever wanted to batch out variations without hand-writing forty prompts, this is the boring, dependable tool for it. Batch 32 frames of a character and let __lighting__, __camera__, and __mood__ roll through their lists while the character stays locked in the prompt. That's the exact workflow people built character reference libraries on back in the SD1.5 era, and it still works today.

    The name is honest: it's a wildcard resolver, nothing more. No API, no key, no model download, no requirements file worth the name (requirements.txt literally says "No external Python dependencies"). If you want a swiss-army dynamic prompt suite with dozens of features, this isn't it. If you want one node that does the thing correctly and stays out of your way, this is very much it.

    How it works

    You point it at a folder of .txt files - say color.txt containing red, yellow, blue, green, one per line - and write The __color__ apple in the prompt box. On generate, the node picks a line and hands you back The blue apple. Same prompt plus same seed always gives you the same picks; change the seed and the lines change.

    Digging into the source, a few details matter. The token regex is __([A-Za-z0-9][A-Za-z0-9_-]*)__, so keys can be letters, numbers, underscores, and hyphens - but no spaces. __red apple__ will silently never match, and you'll get a literal __red apple__ in your prompt where a model can't make sense of it. All picks for a prompt come from a single random.Random(seed) stream, so one seed locks in every wildcard at once. And empty lines are ignored, which is nice until you realize it means a file of nothing but blank lines throws an error, same as a missing key.txt.

    The inputs that matter

    • prompt - the multiline template with your __wildcards__. This is where you do almost all your work.
    • seed - ComfyUI's standard seed widget, with the fixed/randomize/increment controls you expect. Defaults to 0, which means "the same output every time" until you touch it.
    • wildcard_path - absolute or relative path to the folder of wildcard .txt files. It must exist and be a folder, or the node throws a ValueError.
    • string_in (optional) - when you connect something here, it overrides the prompt box entirely. That's your hook for driving prompts from another node.

    Outputs are two: STRING, the fully resolved prompt, and USED_SEED, the seed that produced it. Wire STRING into your CLIP Text Encode and you're done. The second output is the smart play: feed USED_SEED into your KSampler's seed so the noise and the wildcard picks change together. Leave the sampler fixed and you'll get new prompts over the same noise - which is sometimes exactly what you want, and sometimes confusing as hell.

    Installing it

    Easiest route is ComfyUI Manager: search "ComfyUI-Wildcard-Prompt" and install. Manual route is the usual dance:

    cd ComfyUI/custom_nodes
    git clone https://github.com/vpominchuk/ComfyUI-Wildcard-Prompt
    

    Restart ComfyUI. That's the whole install - there's nothing to download and no Python deps to resolve.

    Where people get burned

    Mostly the small things. The wildcard_path error is the classic one - you set it, forget it, and suddenly every generate throws because you moved your folder. Missing or empty wildcard files are loud failures, which is honestly a feature: it beats the silent __color__-in-the-prompt failure mode of sloppier tools. And if you're coming from the bracket-trick school of {red|blue|green} inline variety, note this node doesn't do brackets - it's __file__ or nothing.

    One genuinely good habit: when you find an image you love, keep the resolved STRING around, not the template. The wildcard lines that produced it are worth more than the seed once the files start changing.

    Categoryutils/text

    Inputs (4)

    NameTypeDefaultDescription
    promptSTRINGPrompt template used when no external prompt input is connected.
    seedINT00–18446744073709550000Seed used for deterministic wildcard selection when no external seed input is connected.
    wildcard_pathSTRINGFilesystem path to a folder containing wildcard .txt files.
    string_inoptSTRINGOptional external string input. When connected, it overrides the prompt text field.

    Outputs (2)

    NameTypeDescription
    STRINGSTRING
    USED_SEEDINT