Nodes/SDVN_Comfy_node/🎲 Random Prompt
ComfyUI Node

🎲 Random Prompt

Batch out prompt variations with dynamic-prompt syntax

By StableDiffusionVNΒ·Created 2 years agoΒ·Updated about a month agoΒ· 118
🎲 Random Prompt
    • STRING
    β—„promptSyntax - https://github.com/adieyal/sd-dynamic-prompts/blob/main/docs/SYNTAX.mdβ–Ί
    β—„max_prompts1β–Ί
    β—„seed0β–Ί

    This node takes one prompt written with dynamic-prompt syntax and spits out a list of resolved variations from it - no manual retyping, no separate randomizer script. Write {brown|blonde|black} hair once, ask for a batch of ten, and you get ten prompts with the bracket resolved differently each time.

    The bracket trick, and why it's still worth knowing

    {option_a|option_b|option_c} inside a prompt means "pick one of these at random when this prompt gets resolved." It's old A1111 wildcard syntax that a lot of people who arrived in the ComfyUI era after 2024 never actually learned, but it's still exactly what you want for building prompt variety without writing a dozen near-identical prompts by hand - one popular use is building a character reference library: batch a prompt with {brown|blonde|black} hair and {raining|windy|snowing} weather, and you get the same described subject across a spread of lighting and conditions with zero training involved. This node is the pack's implementation of that syntax as a standalone batch generator, separate from the dynamic-prompt support built into the pack's CLIP Text Encode node.

    The inputs and outputs that matter

    • prompt - your prompt text with bracket alternations ({a|b|c}) and/or wildcard file references (__filename__, pulled from ComfyUI's wildcards folder) written into it. The default field text is literally a link to the syntax reference - worth actually reading if you haven't used this syntax before, since the full grammar (nested brackets, weighted choices) goes beyond the basic pipe-separated case.
    • max_prompts - how many resolved variations to generate, 0–1000, default 1.
    • seed - controls which random choices get made; same seed, same set of resolved prompts.

    One output: a list of resolved STRING prompts. Feed the list into a text encoder downstream and ComfyUI will iterate it across your batch/queue the way list outputs normally do in this ecosystem.

    Installing it

    ComfyUI Manager: search SDVN_Comfy_node, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node
    

    Then pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt from your ComfyUI root, and restart. The pack's README lists the Dynamicprompts node as a recommended companion for full dynamic-prompt support elsewhere in the pack (notably CLIP Text Encode's random ability) - if wildcard file references (__filename__) don't resolve here, installing that node is the first thing to check.

    Where people get burned

    Wildcard files need to actually be in the wildcards folder. The README's convention is /ComfyUI/wildcards for any __filename__-style reference. A wildcard name that doesn't match a file there - wrong path, wrong extension, typo in the reference - just fails to resolve, usually silently rather than with a clear error.

    max_prompts doesn't guarantee unique output. With a small bracket set and a high max_prompts, you'll get repeats - the node is sampling with randomness, not enumerating every combination exhaustively unless your bracket space happens to be that small.

    A fixed seed with the same prompt always gives the same batch. That's a feature for reproducibility, but it trips people up when they expect a "random" node to actually vary between runs - if you want a different set each time, randomize the seed (or set it to increment) the same way you would for image generation.

    CategoryπŸ“‚ SDVN/πŸ’‘ Creative

    Inputs (3)

    NameTypeDefaultDescription
    promptSTRINGSyntax - https://github.com/adieyal/sd-dynamic-prompts/blob/main/docs/SYNTAX.mdβ€”
    max_promptsINT10–1000SΓ΄ lượng prompt tα»‘i Δ‘a tαΊ‘o ra, 0 sαΊ½ tαΊ‘o tα»‘i Δ‘a
    seedINT00–18446744073709550000GiΓ‘ trα»‹ seed ban Δ‘αΊ§u.

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGβ€”