Nodes/Dynamic Prompt Nodes/Prompt with Wildcards
ComfyUI Node

Prompt with Wildcards

One Prompt Template That Fits Every Checkpoint You Own

By cesasol·Created 6 months ago·Updated 4 months ago· 0
Prompt with Wildcards
  • model
  • positive
  • negative
positive_template
negative_template
seed0
ignore_repeatsfalse
cleanup_extra_spacesfalse
cleanup_empty_constructsfalse
model_variant

Here's the workflow headache this node exists to kill: your Pony prompt starts with score_9, score_8_up, your SDXL prompt starts with masterpiece, best quality, and your Flux prompt starts with neither - and every time you swap checkpoints you spend ten minutes editing quality tags by hand. Prompt with Wildcards is the flagship node of the Dynamic Prompt Nodes pack, and its whole trick is that it looks at the model you fed it and decides which quality tags that model wants, inside the prompt itself.

It does this by inferring the model family from the actual model object - SD1, SDXL, SD3, or Flux - plus the Pony/Illustrious/Anima/NoobAI variants, and exposing that as conditionals you can write in plain text. score_9, score_8_up is a Pony ritual; on a plain SDXL model those tags do nothing useful. With this node, one template stays valid no matter which checkpoint you drop in.

How it works

You wire your checkpoint's model output into the node, and it peeks at the model architecture: SD1 has 8 input_blocks, SDXL has 9, SD3 has 16 in_channels, Flux has an img_in attribute. From that it sets system variables like _is_sdxl, _is_pony, _is_sd - and you use them in the template:

<ppp:if _is_pony>score_9, score_8_up, score_7_up</ppp:if>
<ppp:if _is_sdxl and not _is_pony>masterpiece, best quality</ppp:if>

Those <ppp:> tags are the sd-webui-prompt-postprocessor syntax, and this node implements it fully: <ppp:if> / <ppp:elif> / <ppp:else> conditionals, <ppp:set> and <ppp:echo> for variables, <ppp:stn> to route content into the negative prompt, and <ppp:ext lora="name" weight="0.8" /> to emit a proper <lora:name:0.8> tag with trigger words. Wildcards work too, same __name__ syntax as the rest of the pack.

The inputs that matter

Most are self-explanatory, but the ones beginners actually touch:

  • model - required. Your checkpoint/UNET model object, used purely for family inference.
  • positive_template / negative_template - both multiline, both processed with the same seed, so a given seed reproduces the same positive and negative pair.
  • seed - same determinism story as the Random node: fixed seed, fixed prompt.
  • model_variant - optional string override (pony, illustrious, anima, noobai) for when auto-detection gets a checkpoint wrong.
  • ignore_repeats, cleanup_extra_spaces, cleanup_empty_constructs - cleanup toggles, all off by default. ignore_repeats dedupes repeated keywords; the other two tidy up spacing and strip empty tags.

Outputs are positive and negative (both STRING), feeding your positive and negative CLIPTextEncode nodes. Anything you route through <ppp:stn> in the positive template gets merged into the negative output automatically.

Installing it

Same pack as the others - search Dynamic Prompt Nodes in ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/cesasol/dynamic_prompt_nodes
cd dynamic_prompt_nodes
pip install -e .

Dependencies are just lark and pyyaml; there are no model downloads. Wildcards in ComfyUI/custom_nodes/dynamic_prompt_nodes/wildcards/ or ComfyUI/models/wildcards/.

Where people get burned

Two things. First, auto-detection is heuristic - an unusual or patched checkpoint may not match the four families, and then _is_sd flags go wrong; that's exactly what model_variant is for, so don't fight the auto-detect, override it. Second, this node does not have the wildcard dropdown the other three nodes get (the web extension only targets Random, Combinatorial and Cyclical) - type __name__ by hand, and check the path if it stays literal. And remember all three cleanup flags default to off: if your output looks messy with duplicate tags, that's not a bug, flip the switches.

CategoryDynamic Prompts

Inputs (8)

NameTypeDefaultDescription
modelMODEL
positive_templateSTRING
negative_templateSTRING
seedINT00–2147483647
ignore_repeatsBOOLEANfalse
cleanup_extra_spacesBOOLEANfalse
cleanup_empty_constructsBOOLEANfalse
model_variantoptSTRING

Outputs (2)

NameTypeDescription
positiveSTRING
negativeSTRING