HT Dynamic Prompt
Wildcard prompts that stop before the token limit
- clip
- prompt
- token_info
- clip
If you've used A1111's dynamic prompts or the comfyui-dynamicprompts extension, you know the drill: write a template with {option|option} variations and __wildcards__ that pull from text files, and every generation rolls a fresh prompt. HT Dynamic Prompt, from HommageTools, does that inside the pack - with the genuinely useful addition of real token counting, so a template that expands too big gets caught before it hits the CLIP's 77-token wall instead of after.
How it works
It uses the dynamicprompts library under the hood (which is why that package is in the pack's requirements). You give it a template and a seed; it expands the syntax into a concrete prompt.
Inputs:
- text - the template, supporting
{a|b|c}alternatives and__wildcard__references. - seed - makes the expansion reproducible. Same template + same seed = same prompt, every time.
- autorefresh (Yes/No) - refresh the output every time the node evaluates, versus only when something upstream changes. Keep it on "Yes" for batch exploration.
- strip_whitespace (Yes/No) - collapse excess whitespace and linebreaks in the result. Worth enabling when you're pasting into a one-line CLIP encoder.
- max_tokens (default 75) - the cap. The node truncates the expanded prompt to stay under it.
- clip (optional) - plug in your CLIP and it counts tokens with the actual text encoder instead of a rough heuristic. The author's tooltip spells out why: "to avoid token limit errors."
Outputs:
- prompt - the expanded STRING, ready for CLIP Text Encode.
- token_info - a text readout of the token count, handy for debugging.
- clip - passes your CLIP through if you connected one.
The smart part
Token truncation instead of failure is the differentiator. Wildcard combos are combinatorial - a template with three {a|b|c|d} slots has 64 expansions, and a few of them will be long. Most dynamic prompt nodes just throw the long one at CLIP and let it error or silently truncate. This one counts first and trims the expansion to fit max_tokens, which is the difference between a batch job that runs to completion and one that dies on frame 47.
Where it fits
Batch prompt exploration is the whole game: a template with randomized subjects, styles, and camera angles, run across N seeds, gives you a varied contact sheet without writing each prompt by hand. Pair the prompt output with your CLIP encoder and keep seed wired to a seed generator so each run is different but reproducible.
Installing it
Ships with HommageTools, and needs the dynamicprompts pip package (in the pack's requirements). ComfyUI Manager → search HommageTools, or:
cd ComfyUI/custom_nodes
git clone https://github.com/ArtHommage/HommageTools.git
cd HommageTools && pip install -r requirements.txt
Restart ComfyUI.
Gotchas
- Wildcard files are looked up in a
wildcardsfolder (ComfyUI base, then thecomfyui-dynamicpromptscustom node folder). If your__wildcard__comes back literal and unexpanded, the file isn't where it's looking - that's the first thing to check. max_tokenscounts tokens, not characters. 75 is a safe default under the 77-token limit; if you have your own CLIP variant with a different ceiling, set it accordingly.- LoRA tags (
<lora:...>) are stripped before counting so they don't eat your token budget.
For template-driven batch generation, this is one of the more complete dynamic prompt nodes around - and the token guard alone justifies trying it.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
| autorefresh | COMBO | No | Automatically refresh the output on node evaluation |
| strip_whitespace | COMBO | No | Remove excessive whitespace and linebreaks |
| max_tokens | INT | 7510–1000 | Maximum number of tokens in the output prompt (to avoid token limit errors) |
| clipopt | CLIP | CLIP model for accurate token counting |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| token_info | STRING | — |
| clip | CLIP | — |