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

πŸ“ Wildcard Processor

A1111-style wildcards, but with weights and variables

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

    If you've ever seen a prompt online with {red|green|blue} or __hairstyle__ sprinkled through it, you've seen wildcard syntax - it's old A1111 territory, and it's how people get dozens of batched variations of the same scene without touching a single word by hand. MNeMiC's Wildcard Processor is that syntax, dropped into ComfyUI as a single node: feed it a string, get back the resolved text, wire it straight into your CLIP Text Encode. It's part of a bigger grab-bag pack (mnemic-nodes) that also does LoRA tag loading, prompt-property extraction, and a pile of small utility nodes - but the wildcard processor is the one people search for by name, because a lot of people arriving to ComfyUI after 2024 never learned this syntax and it looks like magic the first time they see it resolve.

    What it actually does

    Two mechanisms, and you can mix them freely in the same string. File wildcards - __filename__ - pull a random line out of a .txt file sitting in a wildcard directory (lines starting with # are comments and get skipped). Inline choices - {a|b|c} - pick one option right there in the text, no file needed. A photo of a {red|green|blue} car resolves to one of the three, every run.

    Where this node earns its keep over the plainer version of this syntax you'll find elsewhere in the ecosystem (Impact Pack's wildcard tools, for instance, which stick to __file__ and basic {a|b|c}) is the extra layers stacked on top:

    • Weighted choices - {5::black|green|red} makes black five times as likely as the others. Weights aren't a percentage, they're relative and get normalized against the whole block - {5::red|4::green|7::blue|black} sums to 17 and works out to roughly 29% red, 24% green, 41% blue, 6% black (an unweighted option defaults to weight 1).
    • Select multiple - {2$$a|b|c|d} pulls two items instead of one, {1-3$$...} pulls a random count within that range, and you can set your own join text with {1-3$$, $$red|green|blue|yellow|purple}.
    • Variables - ${animal=!__animals__} defines animal once (here, from a wildcard file) and reuses it: The ${animal} is friends with the other ${animal} resolves to the same animal both times, which plain {a|b|c} syntax can't do by itself.

    That last one is the feature that actually separates this from a toy. Reusing one resolved value across a prompt - same character, same color, same style token repeated in two places - is normally something you'd fake with a second node or manual copy-pasting.

    Inputs and output

    Three inputs, all required. wildcard_string is the multiline text box - your prompt, wildcards and all. seed drives the randomness; same seed, same prompt, same result, which is what makes a good roll reproducible. recache_wildcards is a boolean, off by default - flip it on to force the node to re-read wildcard files from disk (useful right after you've edited or added a .txt file), then you can flip it back off once it's picked up the change.

    One output: processed_text, a plain STRING with every wildcard and tag resolved. Wire it into a CLIP Text Encode or anything else downstream that eats prompt text.

    Installing it

    Search ComfyUI-mnemic-nodes in ComfyUI Manager, install, restart. Or by hand:

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

    then restart ComfyUI. The wildcard node itself needs nothing beyond that - no models, no API key. (The pack does ship a couple of Groq LLM/VLM/audio nodes elsewhere that need a .env file with an API key; that setup step is only for those, not for anything wildcard-related.)

    Where people get stuck

    __filename__ shows up literally in the output. No matching file was found in a wildcard directory the node scans, or the name doesn't match exactly (case and extension both matter - __color__ needs color.txt). Double-check the file actually landed where the node's looking, and toggle recache_wildcards on and run once if you added it while ComfyUI was already running.

    Weighted syntax not behaving how you'd expect. Remember the weights are relative to the sum of the block, not literal odds - {5::black|green|red} isn't "50% black," it's five parts out of seven.

    Same result every single run. That's seed doing exactly what it's supposed to. ComfyUI auto-adds a randomize/fixed control to any widget named seed, so if you want a different roll each queue, check that control isn't stuck on fixed.

    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.