Nodes/Power Prompt/Power Prompt
ComfyUI Node

Power Prompt

The prompt node that makes randomness feel deliberate

By Kramins·Created 2 months ago·Updated 2 months ago· 0
Power Prompt
    • prompt
    • raw_prompt
    yaml_inputvariables: subject: type: select count: 1 options: - 1girl - 1boy art_style: type: select count: 1 options: - anime - oil painting - watercolor sketch mood: type: text prompt: | {{ subject }}, {{ art_style }}, {% if mood %}{{ mood }},{% endif %} masterpiece, best quality
    var_state{}
    seed0

    Yes, yet another dynamic prompt node - the custom-node universe has a few. But this one reads like someone actually uses it. Power Prompt (the class is PowerPromptNode) turns a single YAML block into a whole panel of prompt controls: dropdowns, checkboxes, free-text boxes, and sockets, all feeding one template that gets assembled at generation time. It's the {a|b|c} wildcard trick from the A1111 era, but structured, weighted, and honest about what it's doing instead of hiding it inside a string.

    The pitch, in one sentence: you write a YAML file describing variations, and the node rolls one concrete prompt every run - seeded, weighted, and conditional. Batch 32 images and get 32 different but coherent takes on the same subject, without hand-editing a prompt between runs.

    How it works

    Your YAML has three top-level keys: variables: (required), optional fragments:, and a prompt: Jinja2 template. Each variable is a named slot - type: select picks from a list, text is a free-text box, input creates a node socket. Options can carry a weight (3 means three times as likely as weight 1), a count range (1-3 picks a random number, any lets you tick what you want), and when/unless Jinja2 expressions that decide which options make the pool this run. Variables resolve top-down, so an earlier choice like season == 'winter' can gate everything downstream - including via tags, which accumulate as variables resolve.

    At generation time the node resolves everything in order, builds a Jinja2 context, and renders. The randomness is seeded by the node's seed input, which is the thing that makes Power Prompt feel deliberate rather than chaotic: same YAML, same seed, same prompt. That's the whole loop.

    variables:
      subject:
        type: select
        count: 1
        options:
          - value: 1girl
            weight: 3
          - 1boy
      season:
        type: select
        count: 1
        options: [winter, summer]
    
    prompt: |
      {{ subject }},
      {% if season == 'winter' %}cozy scarf, frosty breath,{% endif %}
      {{ season }}, masterpiece, best quality
    

    The inputs and outputs that matter

    There are three inputs and you'll touch two of them.

    • yaml_input - the entire definition. It ships with a working starter template, which is a nice touch for a first run.
    • seed - drives the random picks. Keep it fixed while you tune your YAML, then roll it for variety. This is the "change one variable at a time with a fixed seed" rule from every troubleshooting thread, applied at the prompt level.
    • var_state - a JSON string that stores your UI selections between runs. It's how the frontend remembers what you picked in the panel. You rarely write it by hand; leave it at its {} default and let the node fill it in.

    The two outputs: prompt is the clean, normalized render (newlines collapsed, commas cleaned) - wire it into your text encoder's positive input and you're done. raw_prompt is the unprocessed template output, handy when you want to see exactly what Jinja produced, or feed a Display Any node while you debug.

    Installing it

    Search "Power Prompt" in ComfyUI Manager and install, or do it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Kramins/comfyui-power-prompt
    cd comfyui-power-prompt
    pip install -r requirements.txt
    

    Then restart ComfyUI. It shows up under the prompt category. The dependencies are the light end of the spectrum - pyyaml, jinja2, pydantic - so no model files, no CUDA-toolkit dance, no 2GB surprise download. It's a hobby project (GPL-3.0) by Kramins, and the main branch tracks active development - if a README feature isn't in your install, check the releases page or CHANGELOG before assuming you broke it.

    Where people get burned

    • Missing prompt: key - the node throws 'prompt' key is missing or empty. Every variable in the world and no template renders nothing.
    • Order matters. when:/unless: can only reference variables declared above them. A condition on a variable below is silently empty, and your option just disappears from the pool.
    • Not your KSampler seed. The node has its own seed input for its random picks. If you randomize the sampler but keep this one fixed, you get prompt variety - great for batches. If you want full reproducibility, lock both.
    • Invalid YAML fails loudly with Invalid YAML: ..., and the message usually names the line.

    Check the examples/ folder - basic.yaml, standard.yaml, advanced.yaml are a fast on-ramp. It's new and barely talked about anywhere, which is exactly why you should look twice: nobody's telling you to use it, but it works.

    Categoryprompt

    Inputs (3)

    NameTypeDefaultDescription
    yaml_inputSTRINGvariables: subject: type: select count: 1 options: - 1girl - 1boy art_style: type: select count: 1 options: - anime - oil painting - watercolor sketch mood: type: text prompt: | {{ subject }}, {{ art_style }}, {% if mood %}{{ mood }},{% endif %} masterpiece, best quality
    var_stateSTRING{}
    seedINT00–18446744073709550000

    Outputs (2)

    NameTypeDescription
    promptSTRING
    raw_promptSTRING