Nodes/ComfyUI-JNodes/Parse Wildcards
ComfyUI Node

Parse Wildcards

File-based prompt randomization with a seed you control

By JaredTherriault·Created 3 years ago·Updated about a month ago· 91
Parse Wildcards
    • STRING
    text
    absolute_path_to_wildcards_directory
    mode
    seed0
    use_same_seed_for_multiple_occurrencesfalse
    inline_wildcards

    If you've ever wanted your prompt to pull a random hairstyle, outfit, or lighting setup from a list every run without editing the text by hand, that's what wildcards are for, and this is JNodes' take on them. You keep a folder of plain .txt files - hair.txt, location.txt, one option per line - and drop a token like __hair__ into your prompt. On each run the node swaps that token for a random line from the matching file. The output is your finished prompt string, ready to hand to a CLIP Text Encode.

    The author's own README calls it "yet another Wildcards implementation," and he's not wrong - file-based wildcards go back to the Automatic1111 days and half a dozen ComfyUI packs do some version of this. What JNodes adds is control over how the randomness happens, which is the part people actually fight with. That's the reason to reach for this one over a barebones wildcard node.

    How it works

    You point the node at a directory of wildcard files, write your prompt with __name__ style tokens, and it resolves each token to a random pick. The mechanism is a straight text substitution done before the prompt ever hits the encoder, so it composes with everything downstream - you can send the result into a normal encode, a token counter, whatever.

    The interesting knob is mode. In seed mode the picks are driven by the seed, so the same seed reproduces the exact same set of choices - critical if you find a combination you like and want it again. In index mode it walks the list positionally instead, which is how you march through every option in order across a batch rather than gambling each time.

    The inputs and outputs that matter

    • text - your prompt with the wildcard tokens in it.
    • absolute_path_to_wildcards_directory - the full path to the folder holding your .txt files. Absolute, not relative, so it doesn't guess wrong.
    • mode - seed (reproducible-by-seed) or index (positional walk).
    • seed - the number that drives the picks in seed mode. Wire it to the same seed source as your sampler if you want the whole run to move together.
    • use_same_seed_for_multiple_occurrences - if a token like __color__ shows up twice in one prompt, turn this on to make both resolve to the same pick instead of two independent rolls. Handy when you want the shirt and the shoes to match.

    There's one optional input, inline_wildcards, a multiline field where you can define wildcard options right in the graph instead of maintaining a file - good for one-offs you don't want to save to disk.

    The single output is a STRING: your prompt with every token resolved. Plug it straight into your text encode.

    How to install it

    Two easy paths. In ComfyUI Manager, search JNodes and install. Or from a terminal:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JaredTherriault/ComfyUI-JNodes
    pip install -r ComfyUI-JNodes/requirements.txt
    

    then restart ComfyUI. JNodes is a broad UX suite - lora/embedding picker, image viewer, the works - but there are no model files to download for the prompt nodes.

    Common issues & troubleshooting

    "It didn't replace anything." Nearly always the directory path. It has to be absolute and point at the folder that actually contains your .txt files, and your tokens have to match the filenames. If this runs on a cloud/serverless ComfyUI where the filesystem is ephemeral, a local wildcards folder won't exist at all - use the inline_wildcards field there instead of a path.

    It picks a new combo every run when you wanted the same one. You're in seed mode but the seed is changing each run (a randomized seed source upstream). Lock the seed to reproduce.

    Two extensions fighting over dynamic prompts. JNodes ships its own prompt-parsing web features. If you also run Comfy's built-in DynamicPrompts they can step on each other - the README says to disable the stock one under ComfyUI Settings → JNodes → Extension Management. Note that's for the {a|b|c} inline-choice syntax (JNodes has a separate node for that); this node is the file-based __name__ flavor.

    Categorywildcards

    Inputs (6)

    NameTypeDefaultDescription
    textSTRING
    absolute_path_to_wildcards_directorySTRING
    modeCOMBO2 options: seed, index
    seedINT0
    use_same_seed_for_multiple_occurrencesBOOLEANfalse
    inline_wildcardsoptSTRINGA list of variable=value pairs, separated by newlines. For example, one line could say 'subject=1girl' and the next line could say 'action=jumping rope'. Then your prompt '__subject__ is __action__' will be replaced with '1girl is jumping rope'.

    Outputs (1)

    NameTypeDescription
    STRINGSTRING