Nodes/Comfyui-CustomizeTextEncoder-Qwen-image/Text Encode Qwen Image Edit (Enhanced)
ComfyUI Node

Text Encode Qwen Image Edit (Enhanced)

The Qwen Edit text encoder that lets you rewrite the system prompt

By chenpipi0807·Created about a year ago·Updated 2 months ago· 38
Text Encode Qwen Image Edit (Enhanced)
  • clip
  • vae
  • image
  • CONDITIONING
prompt
system_template<|im_start|>system You are a Prompt optimizer specialized in character consistency for image editing. Your primary goal is to preserve character identity while implementing requested changes. Character Consistency Priority (CRITICAL): 1. FACIAL FEATURES (HIGHEST PRIORITY): Preserve exact facial structure, face shape, jawline, cheekbones, nose shape, lip shape, eye shape and spacing 2. HAIR: Maintain hair texture, hairstyle, hair color, hair length, and any hair accessories or decorations 3. EYES: Keep exact eye color, eye shape, eyebrow shape and color, eyelash style 4. SKIN: Preserve skin tone, skin texture, any facial markings, freckles, moles, or scars 5. DISTINCTIVE FEATURES: Maintain tattoos, piercings, birthmarks, facial hair style, or unique characteristics 6. CLOTHING/STYLE: Adapt clothing and accessories as requested while keeping character recognizable Task Requirements: 1. When modifying the image, ALWAYS explicitly describe which facial and character features must remain unchanged 2. For brief inputs, add details that enhance the scene while strictly preserving all character-identifying features 3. If text rendering is required, enclose in quotes with position specification 4. Prioritize character recognition over scene/background changes 5. Limit response to 200 words, focusing on character preservation Process: First identify all distinctive character features from the input image, then explain how the requested changes will be applied while maintaining these exact features. Add "Ultra HD, 4K, cinematic composition" for quality enhancement.<|im_end|> <|im_start|>user <|vision_start|><|image_pad|><|vision_end|>{}<|im_end|> <|im_start|>assistant

Qwen-Image-Edit is the open instruction editor everyone reaches for first in 2026: hand it a picture and a sentence and it changes the picture, no mask, no ControlNet, no adapter. ComfyUI ships a built-in TextEncodeQwenImageEdit node for it - but that node bakes in a fixed system prompt, and the model is oddly sensitive to what that prompt says. This node is a drop-in replacement that puts the system prompt back in your hands, pre-loaded with one tuned for keeping the same face across edits.

That's the whole pitch, and honestly it's the whole pack. It's a thin node. But thin here means one job done properly.

Why you'd reach for it

The character-consistency problem is the one that ate the community's attention from 2025 onward, and the practical answer became "generate the character once, then edit that image" instead of trying to encode identity at generation time. Qwen-Image-Edit is the default model for that workflow - but it re-emits the whole frame, so faces drift, and the model's own demo prompt is an "edit instruction rewriter" that mostly cares about clean, concise instructions, not identity. The official ComfyUI node's simplified template waters that down further, which is exactly what this pack's README complains about: too much prompt engineering baked in, character consistency lost.

If you're doing Qwen Edit work in ComfyUI and your characters wander between edits, this is worth ten minutes to try.

How it works

The node is a text encoder, not a model. Internally it swaps the CLIP object's tokenizer for a custom QwenImageTokenizer whose llama_template_images is set to your system_template, tokenizes the prompt and reference image, then puts the original tokenizer back. The template is the whole chat-format preamble: system, user, and assistant turns with the <|vision_start|><|image_pad|><|vision_end|> block where the image gets embedded. The {} in the template is where your prompt lands, and the image placeholder token gets replaced with the actual image tensor.

One detail worth knowing: the encoded output trims everything before the second <|im_start|>, so the system text is influencing the rewrite rather than being dumped into the conditioning verbatim. That's the official ComfyUI behavior, preserved here.

The inputs that matter

  • prompt (STRING, multiline) - your edit instruction, plain language: "change her dress to blue", "remove the watermark". This is what gets inserted into the {} slot.
  • system_template (STRING, multiline) - the whole system prompt in chat format. The default is a character-consistency-optimized one (facial features highest priority, then hair, eyes, skin, distinctive features) that also appends "Ultra HD, 4K, cinematic composition". This is the knob the official node hides from you.
  • clip (CLIP) - the Qwen-Image-Edit text encoder from the model loader.
  • image (IMAGE) and vae (VAE), both optional - the reference image and the VAE. Wire both. The image goes into the context via tokens; the VAE additionally attaches a reference latent, which is the "appearance control" half of the model's dual-encoding design and the thing that actually pins identity.

The single CONDITIONING output feeds straight into the sampler, same as the official node.

Installing it

Via ComfyUI Manager, search Comfyui-CustomizeTextEncoder-Qwen-image, or:

cd ComfyUI/custom_nodes
git clone https://github.com/chenpipi0807/Comfyui-Qwen-image-edit-CharacterConsistency

then restart ComfyUI. There are no pip requirements to install - the pyproject declares nothing, and it only uses transformers and ComfyUI internals you already have. The real heavy lift is the model itself: Qwen-Image-Edit is a 20B MMDiT, so you'll want a GGUF quantization on a consumer card. That download is separate from this node.

Where people get burned

The trap is editing the template wrong. It must keep the chat tokens (<|im_start|>, <|im_end|>, the <|vision_start|> block) and the single {} placeholder - paste in a plain-English system prompt with no tokens and nothing gets formatted right. Also remember the system prompt only nudges the rewrite; it doesn't fix the model's structural drift. If you need untouched pixels to survive exactly, mask the region and crop-and-stitch, because no template rewrites physics.

Categoryadvanced/conditioning

Inputs (5)

NameTypeDefaultDescription
clipCLIP
promptSTRING
system_templateSTRING<|im_start|>system You are a Prompt optimizer specialized in character consistency for image editing. Your primary goal is to preserve character identity while implementing requested changes. Character Consistency Priority (CRITICAL): 1. FACIAL FEATURES (HIGHEST PRIORITY): Preserve exact facial structure, face shape, jawline, cheekbones, nose shape, lip shape, eye shape and spacing 2. HAIR: Maintain hair texture, hairstyle, hair color, hair length, and any hair accessories or decorations 3. EYES: Keep exact eye color, eye shape, eyebrow shape and color, eyelash style 4. SKIN: Preserve skin tone, skin texture, any facial markings, freckles, moles, or scars 5. DISTINCTIVE FEATURES: Maintain tattoos, piercings, birthmarks, facial hair style, or unique characteristics 6. CLOTHING/STYLE: Adapt clothing and accessories as requested while keeping character recognizable Task Requirements: 1. When modifying the image, ALWAYS explicitly describe which facial and character features must remain unchanged 2. For brief inputs, add details that enhance the scene while strictly preserving all character-identifying features 3. If text rendering is required, enclose in quotes with position specification 4. Prioritize character recognition over scene/background changes 5. Limit response to 200 words, focusing on character preservation Process: First identify all distinctive character features from the input image, then explain how the requested changes will be applied while maintaining these exact features. Add "Ultra HD, 4K, cinematic composition" for quality enhancement.<|im_end|> <|im_start|>user <|vision_start|><|image_pad|><|vision_end|>{}<|im_end|> <|im_start|>assistant
vaeoptVAE
imageoptIMAGE

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONING