ComfyUI Node

Prompt Template

One Node That Does Comments, Wildcards, Dynamic Prompts, and $key Substitution

By kinorax·Created 5 months ago·Updated about a month ago· 2
Prompt Template
  • extras
  • string
  • normalized_string
template
suffix
seed

Prompt templates are where ComfyUI gets its "generate lots of variations" superpower. The old A1111 wildcard syntax - __hair_colors__ meaning "pick a random entry from the hair_colors list" - is still the most direct way to get a batch of varied prompts, and Dynamic Prompts-style {a|b} alternatives add another layer. But stringing those features together usually means half a dozen nodes and a pile of glue. IPT-PromptTemplate is a single node that does the whole job: // and /* ... */ comment removal, wildcard expansion, Dynamic Prompts expansion, and $key replacement from extras, with an optional seed for reproducible randomness.

How it works

The template input is multiline and reads like a real template. Comments (// or /*...*/) are stripped - great for leaving yourself notes that never reach the sampler. Wildcards live in ComfyUI/user/info_prompt_toolkit/wildcards/*.txt, and you reference them as __name__ (random pick) or __name__#N (fixed line number), including weighted lines in weight::value format - type __ in the field and it suggests available wildcards. Dynamic Prompts syntax is supported too: {a|b} choices, weighted options, multi-select, ranges, and the @ cycle sampler. $key placeholders get replaced from the extras input (missing keys are left as-is), and suffix is appended after expansion.

The seed input is the reproducibility lever: connect it and the random expansions become deterministic; leave it unconnected and every run is genuinely random - the node is explicitly not_idempotent and re-evaluates every execution. Two outputs: string (the raw rendered prompt) and normalized_string (the same text run through the pack's token normalizer, for feeding caption-formatting or comparison logic).

Inputs and outputs that matter

  • template (required) - the template body with wildcards, comments, and placeholders.
  • seed (optional INT) - determinism for random selection.
  • extras (optional) - the $key replacement source.
  • suffix (optional) - appended after expansion.
  • string / normalized_string (outputs) - raw and normalized results.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/kinorax/comfyui-info-prompt-toolkit.git
cd comfyui-info-prompt-toolkit
pip install -r requirements.txt

Restart, or ComfyUI Manager → "ComfyUI-Info-Prompt-Toolkit". ComfyUI 0.17.0+. No models. Note wildcards are your files in the user/info_prompt_toolkit/wildcards folder - the node reads what you create.

Common issues

If your wildcards aren't showing up, check the folder exists and the filenames match your __name__ references - a missing file silently leaves the placeholder unresolved in some setups, so don't assume failure is loud. When you want reproducible batch output, always connect a seed; forgetting it and wondering why "the same workflow" gives different prompts is the classic walk-into. And watch @ cycle behavior if you use it: it advances per invocation, so it interacts with how many times the node runs in your graph. For serious variation workflows this is genuinely one of the pack's strongest nodes - worth the template setup time.

CategoryInfo-Prompt-Toolkit/Prompt

Inputs (4)

NameTypeDefaultDescription
templateSTRINGPrompt template body. Type __ to suggest wildcards, then # after __name__ for item list.
suffixoptSTRINGString to append to template
extrasoptIPT-ImageInfoExtrasextras used for $key replacement in Dynamic Prompts
seedoptINTOptional seed for deterministic random sampler

Outputs (2)

NameTypeDescription
stringSTRING
normalized_stringSTRING