Nodes/ComfyUI_Hangover-Utils/Text Encode Wildcards
ComfyUI Node

Text Encode Wildcards

Batch variety without writing a new prompt every time

By Hangover3832·Created about a year ago·Updated 2 days ago· 1
Text Encode Wildcards
    • string
    prompt
    seed
    prompt_from_clipboardfalse
    recurive_searchfalse
    wildcardswildcards...

    The {wildcard} trick is one of those ideas that seems like it should be built in: write a portrait of {character} in {setting}, and every run picks a random option from a text file. It's old A1111 wildcard syntax that most people who arrived after 2024 never learned - the KB's prompt-engineering essay covers exactly this bracket trick and its uses (build character reference libraries by batching 32 variations of the same person). Text Encode Wildcards is a small, no-frills implementation of it for ComfyUI: a {placeholder} parser that pulls from the models/wildcards folder, from a pack by the hobbyist author Hangover3832.

    If you already run Dynamic Prompts or the full wildcard suites, this won't tempt you - it's deliberately basic. If you want one file's worth of random prompt variety and nothing to learn, it's the node you reach for.

    How it works

    The node scans your prompt for {...} placeholders. Each key is looked up (case-insensitively) against the .txt files in your ComfyUI/models/wildcards folder and its subfolders, and a random non-empty, non-comment line from the matching file is dropped in. A couple of neat extensions beyond the obvious:

    • A placeholder can name a folder, not just a file - with a trailing * on the key, like {characters*}, a random file from that folder is chosen. {*} picks from any file in the wildcards root.
    • Lines starting with # are treated as comments and skipped.
    • seed is used to seed the random picker, so a fixed seed gives you a reproducible prompt - same seed, same wildcard choices, every time. That pairs with the seed-widget trap the KB documents: with control_after_generate on randomize, the pick changes every run, and the number you see in the box is the one that will be used next, not last.

    Inputs that matter

    • prompt - your text with {placeholders}. This is the field that actually drives everything.
    • seed - lock it for reproducibility, randomize for variety.
    • prompt_from_clipboard - when on, the prompt box is ignored and the current clipboard text becomes the prompt (handy for testing prompts you're iterating on elsewhere). Validation errors if the clipboard is empty.
    • recurive_search - note the author's spelling; it controls whether folder matches descend into subfolders.
    • wildcards - a dropdown listing every wildcard file/folder it found. It's a cheat-sheet of what you can reference; the selection itself doesn't drive replacement. The real syntax lives in the prompt box.

    The single output, string, wires straight into a CLIP Text Encode (positive or negative).

    Install

    ComfyUI Manager: search ComfyUI_Hangover-Utils, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Hangover3832/ComfyUI_Hangover-Utils
    

    then restart. The pyperclip dependency in requirements.txt covers the clipboard feature; Manager installs it. No model downloads. To get started, drop any .txt files into ComfyUI/models/wildcards/.

    Common issues

    • Nothing replaces, yellow warning in console - "No wildcards files could be found." Your files aren't in models/wildcards (or the key you typed doesn't match a file/folder stem, which are listed in the dropdown).
    • Empty folder - a folder that resolves to no .txt files is skipped with a warning, leaving the placeholder in place.
    • "Cannot paste, clipboard is empty" - prompt_from_clipboard is on and the clipboard has no text. And on Linux, pyperclip needs xclip or xsel installed or even a full clipboard will read as empty - same class of platform trap as the pack's clipboard image node.
    CategoryHangover

    Inputs (5)

    NameTypeDefaultDescription
    promptSTRING
    seedINT0–9223372036854776000
    prompt_from_clipboardBOOLEANfalse
    recurive_searchBOOLEANfalse
    wildcardsCOMBOwildcards...0 options:

    Outputs (1)

    NameTypeDescription
    stringSTRING