ComfyUI Node

Dynamic Prompt

The Dynamic Prompt node

By Kaleidia·Created 12 months ago·Updated 2 days ago· 0
Dynamic Prompt
    • Prompt
    templateA {happy|sad} __videogamechars/male__ with {1-3$$__color__}
    seed0
    join_styleperiod
    use_historyfalse
    clear_historyfalse
    history_limit3
    debugfalse
    clear_cachefalse

    If you've ever found yourself re-typing the same prompt and just swapping "blonde" for "brunette" to squeeze variety out of a model, this is the node for you. Dynamic Prompt is the flagship of the small KaleidiaNodes pack, and it does what the old A1111 wildcard crowd has been doing for years: you write one template, it rolls a fresh prompt every run. Character sheets, outfit variations, batch reference libraries - all without babysitting the text box.

    The syntax is the familiar dynamic-prompt grammar, and it's worth knowing the full set because this node packs a lot of it in. {blue|red|green} picks one option. {2$$blue|red|green} picks two of them (the README's own example, and yes, you read the double-dollar right). {0.7::red|blue|1.5::green} weights the draw - no need for the weights to sum to anything, green just gets picked more often. And __folder/file__ pulls options straight from a wildcard file, which is where this node gets serious.

    Where the wildcards live

    Wildcard files go in ComfyUI/wildcards/, not inside the pack folder. Drop color.txt in there with one option per line and __color__ in your template picks a line. It reads .txt files including subfolders (and supports * as a "give me everything under this prefix" match), but it also goes one step past most wildcard nodes: .yaml and .json files work too, with top-level keys as the path segments. So __videogamechars/male__ can resolve through nested YAML. The default template in the node - A {happy|sad} __videogamechars/male__ with {1-3$$__color__} - is a working example of every feature at once.

    The inputs that matter

    • template - the multiline text box with all your choices and wildcards. This is the whole node.
    • seed - set it to replay a specific roll, or leave at 0 to keep rolling.
    • join_style - how the pieces from a {2$$...} repetition get glued: space, period, comma, or and. Defaults to period, so three colors come out "red. blue. yellow." instead of "red blue yellow".
    • use_history / history_limit - remembers the last N choices for the session and won't repeat them. With a 30-entry wildcard, set history_limit to 30 and get 30 unique outputs in a row.
    • clear_history and clear_cache - the first wipes that memory; the second rebuilds the wildcard file cache on each run, which you want if you're editing your wildcards while ComfyUI is up. Leave it off otherwise, it's a disk hit every generation for nothing.

    The single output is Prompt, a STRING, and it wires straight into a CLIP Text Encode node's positive input. No API, no key, no model download - it's a pure text generator.

    Installing it

    ComfyUI Manager: search "KaleidiaNodes" and install. Or the manual way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Kaleidia/KaleidiaNodes
    # restart ComfyUI
    

    This is one of the rare packs with zero Python dependencies beyond what ComfyUI already ships (no requirements.txt at all), so nothing else to babysit.

    Where people get burned

    The wildcard cache is built once per ComfyUI session. Edit a .txt file mid-run and the node keeps serving the old options until you toggle clear_cache, reboot, or - the trick that usually works first - just restart ComfyUI. Also remember the files have to be in ComfyUI/wildcards/; dropping them next to your workflow or inside the pack folder gets you a quietly unresolved __token__ in the output. And if you use ComfyUI's own built-in Dynamic Prompts, note this node processes its template itself, so don't expect the two systems to interact. Debug toggle prints the full resolution trace to the console - genuinely handy the first time something doesn't resolve, and harmless to leave on while you're learning.

    CategoryKaleidiaNodes/PromptNodes

    Inputs (8)

    NameTypeDefaultDescription
    templateSTRINGA {happy|sad} __videogamechars/male__ with {1-3$$__color__}
    seedINT00–18446744073709550000
    join_styleCOMBOperiodA connector for repetitive prompt parts. Defaults to '. '. Example 3 colors: red. blue. yellow. or with and option: red and blue and yellow
    use_historyBOOLEANfalsePrevents the same wildcard option from being picked twice until history is cleared.
    clear_historyBOOLEANfalseWipes the history of used options for this session.
    history_limitINT31–100How many previous choices to remember and avoid.
    debugBOOLEANfalseGives debug output to the console about the processing of the dynamic prompt. Default is false to not spam the console.
    clear_cacheBOOLEANfalseClears the wildcard cache on every run. Good if you work on the wildcards on the side during image generation and do not want to completely reboot comfy. Bad as it does disk operations on every run, that might not be needed. Default is false which has the cache build once per comfy run and reused then.

    Outputs (1)

    NameTypeDescription
    PromptSTRING