Nodes/ComfyUI-PainterNodes/Painter Prompt Rewriter
ComfyUI Node

Painter Prompt Rewriter

Your LLM prompt-polish, inside ComfyUI

By princepainter·Created 7 months ago·Updated 6 days ago· 194
Painter Prompt Rewriter
  • clip
  • images
  • generated_text
prompt
template
max_length2048
sampling_mode
max_image_long_side960
thinkingfalse
use_default_templatetrue
use_chatml_systemfalse

"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_penalty slightly, nudge temperature down, or check that your clip actually 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.

Categorytext

Inputs (10)

NameTypeDefaultDescription
clipCLIP
promptSTRINGThe simple prompt to be rewritten.
templateSTRINGThe target format / instruction template the rewrite must follow.
max_lengthINT20481–32768
sampling_modeCOMBO2 options: [object Object], [object Object]
max_image_long_sideoptINT960256–4096Downscale each reference image so its long side is at most this value before it is sent to the model.
thinkingoptBOOLEANfalseOperate in thinking mode if the model supports it.
use_default_templateoptBOOLEANtrueApply the built-in chat template of the model.
use_chatml_systemoptBOOLEANfalseExperimental: inject the template as a ChatML system message instead of user text.
imagesoptCOMFY_AUTOGROW_V3

Outputs (1)

NameTypeDescription
generated_textSTRING