Nodes/ComfyUI-N-Nodes/Dynamic Prompt
ComfyUI Node Runs on cloud

Dynamic Prompt

Pull a random handful of tags out of a list, every run

By Nuked88·Created 3 years ago·Updated 2 years ago· 237
Dynamic Prompt
    • STRING
    variable_prompt
    cachedNO
    number_of_random_tagRandom
    fixed_number_of_random_tag1
    fixed_prompt

    This is ComfyUI's version of the classic "wildcards" idea from the A1111 days: instead of writing one fixed prompt, you give the node a pool of comma-separated tags and let it pick a random subset each time the graph runs. Useful for batch-generating variations without hand-editing the prompt between every queue, or for keeping a base composition steady while the details shuffle.

    How it works

    You fill variable_prompt with your tag pool, comma-separated. The node then samples from that pool - either a fixed count you set yourself, or a random count each run, depending on number_of_random_tag. If it's set to "Fixed," fixed_number_of_random_tag controls exactly how many tags get pulled every time. If it's "Random" (the default), the count itself varies from run to run, so you get both a different selection and a different amount of variation each time. Optionally, fixed_prompt lets you glue a constant string onto the front - your locked-in subject and style, with the randomly selected tags appended as the variable part.

    It's flagged as an output node, which in practice means ComfyUI treats its result as something worth surfacing on its own - the generated string shows up directly rather than silently sitting unused if nothing happens to consume it further downstream.

    The inputs and outputs that matter

    The ones you'll actually touch: variable_prompt (your tag pool), number_of_random_tag (Fixed vs Random), and fixed_number_of_random_tag (how many, when Fixed). fixed_prompt is optional and worth using once you know what you like - it's the difference between "totally random tags" and "my composition, with some controlled randomness on top." cached (default NO) is worth knowing about: set it to YES and the node keeps its last selection instead of rerolling, which is handy when you're tweaking an unrelated part of the graph and don't want the prompt to shift under you mid-comparison.

    Output is a single STRING - wire it straight into a CLIP Text Encode node like you would any other prompt string.

    Installing the pack

    • ComfyUI Manager - search "ComfyUI-N-Nodes," install, restart.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/Nuked88/ComfyUI-N-Nodes.git, then restart ComfyUI.

    No models or extra dependencies for this one - it's pure string manipulation, no GPU involved.

    Common issues & troubleshooting

    The same tags keep coming back every run. Check cached - if it's set to YES, the node deliberately reuses its last result instead of rerolling. Flip it to NO if you actually want a fresh random pick each time.

    Output looks empty or barely varies. With number_of_random_tag on "Fixed" and fixed_number_of_random_tag set higher than the number of tags actually in your pool, you'll get whatever's there and nothing more - the node can't invent extra tags. Count your comma-separated entries and keep the fixed count at or below that.

    A workflow from before February 2024 shows a red or missing node here. The pack renamed its internal classes around that date. Use the migration tool it ships - migrate.bat on Windows or python libs/migrate.py path/to/workflow.json on Linux - rather than trying to fix the JSON by hand.

    CategoryN-Suite/Conditioning

    Inputs (5)

    NameTypeDefaultDescription
    variable_promptSTRING
    cachedCOMBONO2 options: YES, NO
    number_of_random_tagCOMBORandom2 options: Fixed, Random
    fixed_number_of_random_tagINT1
    fixed_promptoptSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING