Nodes/ComfyUI-mnemic-nodes/πŸ“ Wildcard Processor
ComfyUI Node

πŸ“ Wildcard Processor

Your prompt shouldn't be the same sentence every run

By MNeMoNiCuZΒ·Created 3 years agoΒ·Updated a day agoΒ· 105
πŸ“ Wildcard Processor
    • processed_text
    β—„wildcard_stringβ€”β–Ί
    β—„seed0β–Ί
    β—„recache_wildcardsfalseβ–Ί

    Why you'd reach for this

    If you're batching and your prompt is one frozen sentence, you're paying for twenty images and getting one idea. The cheap fix is wildcards - {brown|blonde|black} inside a single prompt, batch 16, and every run picks a different combination. It's old A1111 syntax that anyone who arrived after 2024 mostly never learned, and it's still the fastest way to build a character reference library or a wallpaper set without training anything.

    Impact Pack quietly owns __wildcard__ and {a|b|c} handling for a big slice of the ecosystem, with the Dynamic Prompts lineage on top. This is the version that behaves like a normal node: no extension to enable, no model download, real seed control, and it shows you what it resolved.

    How it resolves, actually

    The mechanism is a loop, not a parser pass. It substitutes any defined variables, expands the innermost {...} block, then swaps __file__ wildcards, and repeats until the text stops changing - capped by the Max Nested Passes setting (default 10) under Settings β†’ ⚑MNeMiC Nodes β†’ Wildcard Processing. Resolved chunks are protected between passes, so a wildcard line that itself contains {braces} comes out intact instead of getting re-eaten.

    File wildcards don't need an exact filename. The node scans every wildcard folder recursively and scores candidates: an exact name wins, and a file in a subfolder you named beats a same-named file at the root. Fuzzy word matching (_, - and spaces interchangeable, word order irrelevant) exists but is off by default - flip on Fuzzy Search in that settings group if __color hair__ should find hair_color.txt.

    Wildcard files live in ComfyUI/wildcards/, the pack's own wildcards/ folder (it ships sample_colors.txt), or any path you add to the pack's wildcards_paths_user.json. One option per line, .txt, # starts a comment, empty lines are dropped. UTF-8, with a latin-1 fallback if your file isn't.

    The syntax in one breath: __animal__ for a file line, {red|green|blue} for inline choices, {5::black|green|red} for weights (normalised across the block), {3$$red|green|blue|yellow} to pick three, {1-3$$...} for a random count, {1-3$$, $$...} to join with your own separator, ${animal=!__animals__} ... ${animal} to roll once and reuse, __*color*__ to glob across files.

    The inputs and output that matter

    Three inputs. wildcard_string is the whole feature set - its own tooltip documents every syntax above, so you don't need this page open to use it. seed is the one people skip: the node calls random.seed(seed), so same seed plus same template gives you the identical prompt, which is how you change steps or CFG while holding the prompt still. recache_wildcards forces a re-scan from disk - on once after adding files, off again.

    One output: processed_text. Wire it into the positive CLIP Text Encode (Prompt), or into anything else that takes a string - a filename prefix, a Groq prompt, another node's text field.

    It's an output node and renders the resolved text inside itself, so you can hit Run with nothing connected and watch it make the pick - do that before you queue 50 images.

    Install

    Easiest route is ComfyUI Manager: search ComfyUI-mnemic-nodes, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MNeMoNiCuZ/ComfyUI-mnemic-nodes
    

    No checkpoints, no model downloads - this is pure text. The pack does pull colorama, groq, transformers, tiktoken, opencv-python and friends for its other 40-odd nodes, and it uses ComfyUI's V3 node API, so keep ComfyUI reasonably current or the pack won't import at all.

    Where it bites

    Unresolved wildcards stay in your prompt, literally. Typo __animalz__ and the sampler receives __animalz__ as text. No error, no red node, just a weird image. That's the number one confusion with every wildcard node out there; turn on Console Logging in the Wildcard Processing settings and it lists the candidate files per name, plus a warning when nothing matched at all.

    The cache lies to you for a run. The file list is scanned at load and contents are cached per wildcard name, with no modification check. Add or edit a .txt and the same prompt keeps handing back the old result until you flip recache_wildcards on once. A failed lookup is cached too, so adding the missing file may not help until you recache.

    Also: don't run Impact Pack's Dynamic Prompts wildcard node and this one on the same prompt - two engines means double processing and seeds that no longer explain the output. And if you want variations within one batch, a different prompt per image rather than one prompt per queue, that's the pack's Batch Wildcard Upscale Sampler.

    The resolved prompt is what lands in your PNG metadata, so you can read back which pick made which image - though that metadata carries your wildcard file paths too.

    Bottom line

    For flat .txt lists, inline choices and weights, this is the least annoying thing in the category, and the on-node preview plus real seed makes it debuggable. If your lists live in YAML or nested dictionaries, you're flattening them to text files or using a different node - this one reads one-option-per-line .txt and isn't apologetic about it.

    Category⚑ MNeMiC Nodes

    Inputs (3)

    NameTypeDefaultDescription
    wildcard_stringSTRINGThe text prompt to process. Supports multiple features: File Wildcards: Use __filename__ to insert a random line from filename.txt in one of the supported wildcard directories. Lines starting with # are treated as comments and are ignored. Inline Choices: Use {a|b|c} to randomly choose between a, b, or c. Example Input: A photo of a {red|green|blue} car. Example Output: A photo of a green car. Weighted Choices: Use {5::black|green|red} to make black 5 times more likely to be chosen than green or red. Weights are normalized to 100% based on the sum of all weights in the block (e.g. {5::red|4::green|7::blue|black} sums to 17, giving red ~29%, green ~24%, blue ~41%, black ~6%). Select Multiple Wildcards: Use {2$$a|b|c|d} to output a specific number of items from the result. Example Input: My favorite colors are {3$$red|green|blue|yellow|purple}. Example Output: My favorite colors are blue, yellow, purple. Ranged Select Multiple: Use {1-3$$red|green|blue|yellow|purple} to select a random number of 1-3 items within a range. Custom Separator: Use {1-3$$, $$red|green|blue|yellow|purple} to join the selected items with a custom separator (here, ", ") instead of the default. Variables: Define a variable to reuse a value. Can be defined directly, or using a wildcard Example Input: ${animal=!__animals__} The ${animal} is friends with the other ${animal}. Example Output: The cat is friends with the other cat.
    seedINT00–18446744073709550000The seed for the random number generator. Using the same seed with the same prompt will produce the same output.
    recache_wildcardsBOOLEANfalseForce a reload of all wildcard files from disk. Can be disabled again after you have ran it once.

    Outputs (1)

    NameTypeDescription
    processed_textSTRINGThe final text after all wildcards and tags have been processed.