Prompt
Wildcards, weighted mixes, file loading, token counts — and a local LLM rewrites your prompts
- prompt
- negative
- all_prompts
- token_count
Prompt tooling is a whole ecosystem of separate packs, and the Prompt node from Utility-MegaPack tries to fold the useful 80% of it into one dropdown. Ten modes: pick a prompt from a batch by index, load prompts from a .txt/.csv file, expand __wildcards__, weight-mix two prompts, render a Jinja template, clean up a prompt (collapse whitespace, fix double commas, dedupe phrases), auto-build a negative, join a list of prompts, count tokens, and - new in v0.3 - llm_enhance_prompt, which sends a rough prompt to a local LLM and gets back a proper one.
Which modes are actually worth reaching for? wildcard_expand and prompt_from_file are the two that replace dedicated wildcard and prompt-batch packs for most people. token_count is genuinely useful because it gives you a number to hang a workflow decision off of. And if you already run Ollama or LM Studio locally, llm_enhance_prompt is a cheap way to get an LLM in the loop without shipping your prompts to a cloud API.
How it works
Every mode is a registered operation on the same node - pick mode, and the relevant widgets show themselves. Outputs are prompt, negative, all_prompts (a LIST), and token_count (INT); only the slots your mode fills are live.
wildcard_expandreplaces each__key__intextwith a random pick fromwildcards_json[key]- pools are defined in a JSON widget, not as files in a wildcards folder like some packs.prompt_mixemits(a:weight_a) (b:weight_b), the Auto1111 attention syntax. Keep in mind that syntax only does something on CLIP-encoded models - LLM-encoded models read those parentheses as literal punctuation.negative_auto_buildtakes apreset(realistic / anime / landscape / none) and emits a stock negative; thepositiveinput is accepted for pairing but not modified.token_countis a word-plus-punctuation heuristic, not a real CLIP tokenizer - treat it as approximate, and warn at the 75/150 boundaries if you're targeting SD 1.5/SDXL CLIP.llm_enhance_prompthitsbase_url(defaulthttp://127.0.0.1:11434, Ollama) with yourprompt, astyledirective, and optionalsystem_prompt. It tries Ollama's/api/chatfirst and falls back to the OpenAI-style/v1/chat/completionsendpoint, so LM Studio and llama.cpp server work too.
Installing it
Ships with the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-Utility-MegaPack
Restart ComfyUI, or use ComfyUI Manager → "Utility-MegaPack". No model downloads for the prompt ops themselves. llm_enhance_prompt does need a running local LLM server and its model (e.g. Ollama with llama3.2), but that's your machine, not the node's.
Where people get tripped up
The local-LLM mode is where beginners trip. The pack blocks HTTP to localhost by default as an SSRF safeguard, and this node respects that - so if llm_enhance_prompt throws a "http to internal address blocked" error, set UTILITY_MEGAPACK_ALLOW_INTERNAL_HTTP=1 in your environment and restart. That env var is the escape hatch for exactly this use case. Also set a realistic timeout_seconds; first-time model loads on Ollama can take a while. And don't expect the token counter to match your text encoder's real tokenizer to the digit - it's a rough ruler, and on LLM-encoded models the whole 77-token mental model is obsolete anyway. Where people get burned most often, though, is the wildcard JSON: if the pool key has a typo, the __key__ is just left in the text, silently.
Inputs (24)
| Name | Type | Default | Description |
|---|---|---|---|
| mode | COMBO | llm_enhance_prompt | 10 options: llm_enhance_prompt, negative_auto_build, prompt_batch_pick, prompt_clean, prompt_from_file, prompt_join_list, +4 |
| theme | COMBO | (use pack default) | 17 options: (use pack default), (use ComfyUI default), cyberpunk, minimalist, glassmorphic, retro_terminal, +11 |
| promptsopt | STRING | — | |
| indexopt | INT | 0 | — |
| pathopt | STRING | — | |
| seedopt | INT | -1-1–4294967295 | — |
| textopt | STRING | — | |
| wildcards_jsonopt | STRING | {} | — |
| aopt | STRING | — | |
| weight_aopt | FLOAT | 1.000–5 | — |
| bopt | STRING | — | |
| weight_bopt | FLOAT | 1.000–5 | — |
| templateopt | STRING | — | |
| vars_jsonopt | STRING | {} | — |
| dedupeopt | BOOLEAN | true | — |
| positiveopt | STRING | — | |
| presetopt | COMBO | realistic | 4 options: realistic, anime, landscape, none |
| separatoropt | STRING | , | — |
| promptopt | STRING | — | |
| modelopt | STRING | llama3.2 | — |
| base_urlopt | STRING | http://127.0.0.1:11434 | — |
| styleopt | COMBO | detailed | 5 options: detailed, cinematic, photoreal, concept_art, minimal |
| timeout_secondsopt | INT | 605–600 | — |
| system_promptopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| negative | STRING | — |
| all_prompts | LIST | — |
| token_count | INT | — |