Painter Prompt Rewriter
Your LLM prompt-polish, inside ComfyUI
- clip
- images
- generated_text
"Write a prompt for this" is the most common thing people hand to an LLM, and video models are the most demanding audience: LTX wants a paragraph, Wan wants structure, and your one-liner won't cut it. PainterPromptRewriter is an in-graph LLM call that takes a short prompt, rewrites it to match a template you specify, and - the useful bit - can look at up to nine reference images while it does. No external API, no key, no network round-trip: it runs on the text-generation capability inside the CLIP model you already have loaded.
What it is
A text category node that returns a single generated_text string. Required inputs are clip (the model providing generation), the prompt to rewrite, a template describing the target format, max_length (default 2048), and a sampling_mode control. Optional inputs add the reference images, a max_image_long_side cap, and three behavior toggles.
How it works
It uses the same interface as ComfyUI core's TextGenerate node - clip.tokenize / clip.generate / clip.decode - so it's running the LLM-style text generation inside the CLIP, not a separate model you have to install. The template is the real power: you paste the exact format your video model wants (the LTX-style long-prompt guide, a Wan prompt skeleton, whatever you've settled on) and the node rewrites your rough idea into that shape. sampling_mode opens a DynamicCombo with the sampling knobs - temperature, top_k, top_p, min_p, repetition_penalty, seed, presence_penalty - which you mostly leave alone until output gets repetitive or bland.
The reference images (up to 9) are downscaled to max_image_long_side (default 960) before being sent, so the model can describe or incorporate what it sees. thinking (if the model supports it) gives it a reasoning pass; use_default_template applies the model's built-in chat template; use_chatml_system is the experimental option that injects your template as a ChatML system message instead of user text - flip it if you're getting ignored instructions.
The inputs that matter
- prompt - what you want said.
- template - the format to force. This is the node's entire personality; spend time here.
- clip - the generation model (any CLIP that supports generate).
- images / max_image_long_side - optional visual guidance.
- sampling_mode - advanced; leave defaults until output quality needs tuning.
Output: generated_text → wire into your prompt/CLIP text encode.
Install
Part of the PainterNodes pack. ComfyUI Manager → search "PainterNodes" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/princepainter/ComfyUI-PainterNodes
cd ComfyUI-PainterNodes
pip install -r requirements.txt
Common issues
- Template ignored - try
use_chatml_system(the experimental toggle exists for exactly this), or check your template actually describes the output shape rather than just stating a goal. - Garbage or repetitive output - raise
repetition_penaltyslightly, nudgetemperaturedown, or check that yourclipactually supports text generation at all. Not every CLIP does. - Node won't load - it's built on the newer ComfyUI node API; update ComfyUI core. Same story as the rest of this pack's newest nodes.
It's a small node that saves a huge amount of tab-switching - the "go paste my idea into ChatGPT, get a paragraph back, come paste it in" loop, done inline. And because it can see your reference images, it's genuinely better at the job than the generic LLM tab.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| prompt | STRING | The simple prompt to be rewritten. | |
| template | STRING | The target format / instruction template the rewrite must follow. | |
| max_length | INT | 20481–32768 | — |
| sampling_mode | COMBO | 2 options: [object Object], [object Object] | |
| max_image_long_sideopt | INT | 960256–4096 | Downscale each reference image so its long side is at most this value before it is sent to the model. |
| thinkingopt | BOOLEAN | false | Operate in thinking mode if the model supports it. |
| use_default_templateopt | BOOLEAN | true | Apply the built-in chat template of the model. |
| use_chatml_systemopt | BOOLEAN | false | Experimental: inject the template as a ChatML system message instead of user text. |
| imagesopt | COMFY_AUTOGROW_V3 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| generated_text | STRING | — |