Nodes/ComfyUI Random Wildcard Loader/Random Wildcard Loader
ComfyUI Node

Random Wildcard Loader

Random prompts that repeat on the same seed — wildcards without the bloat

By BWDrum·Created 8 months ago·Updated 8 months ago· 1
Random Wildcard Loader
    • combined_text
    num_files1
    seed0
    prompt
    loaded_contents
    loaded_wildcards
    refreshfalse

    If you've ever envied A1111 users their __colors__ wildcard prompts, this is the ComfyUI version without the guilt of installing a 50-node pack to get one feature. Random Wildcard Loader is a small, dependency-free text node that swaps placeholders in your prompt for random lines from text files. Bump the seed, get a different prompt. Same seed, same prompt. That's the whole loop, and it makes batch variety feel effortless.

    Wildcards are an old idea. The __wildcard__ syntax has been kicking around since the A1111 days - Impact Pack is what quietly made it standard in ComfyUI - and the bracket trick {a|b|c} is its simpler cousin. This node is a focused take on the same concept: it reads every .txt file in a wildcards/ folder at your ComfyUI root (created automatically on first run), treats each non-empty line as one option, and picks randomly. The author's own pitch is prompt adherence testing - run one skeleton prompt across a hundred random fills and see which details your model actually obeys - but most people just want to stop generating the same five images every time they hit queue.

    How it works

    Type a template in prompt and use two kinds of placeholder. __colors__ grabs a random line from colors.txt. __styles/artistic__ reaches into a subfolder. And $prompt (Mad Libs style) pulls a random line from a randomly chosen file anywhere in the folder - handy when you don't care which category the filler comes from. $$prompt escapes it if you ever need the literal text.

    The node also picks num_files random wildcard files and appends one line from each to the output, joined with newlines. That newline join is hardcoded in the basic node - if you want commas between parts, the Advanced sibling has a separator field.

    Here's the bit that trips people up. ComfyUI caches node results, and this node's cache key is just the seed - so hitting queue again without changing anything returns the same text every time. That's deliberate: the node seeds Python's random at the start of every run, so the same seed always reproduces the same draw. To roll fresh, change the seed or flip refresh. This is what makes it safe to use in automated batches.

    Inputs and outputs

    Only a few of these matter on day one:

    • prompt - your template with __wildcard__ and $prompt placeholders. The one you'll actually type in.
    • seed - controls the draw. Bump it for variety.
    • num_files - how many random wildcard files to also append a line from (0–100, default 1).
    • refresh - a "Refresh/Cached" toggle that forces the node to re-run when you flip it.

    loaded_contents and loaded_wildcards look like inputs but are really readouts - a small JS extension writes the expanded text and the list of which wildcards fired into them after each run, so you can see exactly what got picked. The single output, combined_text, is a STRING that plugs straight into the text input of a CLIP Text Encode node.

    Install

    ComfyUI Manager is easiest - search "Random Wildcard Loader" and install. Or, from your ComfyUI folder:

    cd ComfyUI/custom_nodes
    git clone https://github.com/BWDrum/ComfyUI-RandomWildcardLoader.git
    

    Restart ComfyUI. No pip dependencies, no model downloads - the whole thing is one Python file plus a bit of JS.

    Gotchas

    A missing wildcard doesn't error, it passes through. If __colors__ doesn't resolve (typo, wrong folder), you get the literal __colors__ in your prompt, and the image may well render "colors" as junk text - the same silent-failure pattern as a mistyped embedding. Same with $prompt when your wildcards folder is empty: it stays literal. The loaded_wildcards readout is your friend - if a name shows up there untouched, you've got a path problem.

    Also, wildcard lines are raw text. No filtering, no dedup, so a line that's just "the" will happily ride along. Keep your files curated and you get variety instead of nonsense.

    Categorytext/wildcards

    Inputs (6)

    NameTypeDefaultDescription
    num_filesINT10–100
    seedINT00–18446744073709550000
    promptSTRING
    loaded_contentsSTRING
    loaded_wildcardsSTRING
    refreshBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    combined_textSTRING