Nodes/Sage Utils/Single CLIP Text Image Encode
ComfyUI Node

Single CLIP Text Image Encode

Encode prompt + reference image in one node, and zero the parts you skip

By arcum42·Created 2 years ago·Updated 28 days ago· 33
Single CLIP Text Image Encode
  • clip
  • vae
  • image
  • conditioning
  • text
cleantrue
text

For the Qwen-Image-Edit line of models, a prompt isn't just a prompt - it can be text, an image, or both, and the conditioning has to encode whichever combination you actually provide. That's what this node handles: it turns your prompt into conditioning for an edit model, passes the text through so you don't lose it, and - the clever part - automatically zeroes the conditioning when you hook up neither text nor image. No dangling empty conditioning, no garbage tokens.

How it works

It builds a subgraph around ComfyUI's TextEncodeQwenImageEdit node, which is the edit-model text encoder: it takes a clip, an optional text prompt, an optional image, and an optional vae (needed to encode the image). Under the hood the node wires those into the encoder, and if both text and image are left unconnected, it routes the result through ConditioningZeroOut so you get a zeroed conditioning instead of an empty encoding that might misbehave downstream. If only one is connected, that one is used.

The clean toggle (default on) tidies your text - stripping extra spaces, commas, and formatting noise - before encoding, which matters more than it sounds on edit models where the text is an instruction. The outputs are conditioning (ready for the sampler) and text, the cleaned prompt string, which you can route into a metadata node so the recorded prompt matches what was encoded.

Where it sits in the graph

It's the single-encode flavor of the pack's Qwen/image-edit conditioning nodes - there's a dual version that does positive and negative in one node. In a typical edit workflow you'll run this before a Reference Image node (or use it to encode the text alongside the reference image), then feed the conditioning to the sampler. Because it handles the "nothing hooked up" case for you, it plays nicely with workflows where you toggle between text-to-image and image-editing runs without rewiring.

Installing it

Sage Utils via ComfyUI Manager (search Sage Utils) or:

cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils
cd ComfyUI_SageUtils
pip install -r requirements.txt

Restart ComfyUI. The pack's only pip dependency is dynamicprompts; no downloads needed for this node beyond the model itself.

The trap to avoid

This encoder expects an edit-style model (Qwen-Image-Edit and friends) - plug a vanilla CLIP model into it and you're asking the wrong encoder to do a job it isn't built for. Check the model's docs before assuming the TextEncodeQwenImageEdit path is what your checkpoint wants. And remember: if you connect an image, you need a VAE on the vae input or there's nothing to encode the pixels with.

CategorySage Utils/clip/encode/image

Inputs (5)

NameTypeDefaultDescription
clipCLIPThe CLIP model used for encoding the text.
cleanBOOLEANtrueClean up the text, getting rid of extra spaces, commas, etc.
vaeoptVAEThe VAE model used for encoding the reference image.
textoptSTRINGThe prompt's text.
imageoptIMAGEThe prompt's image.

Outputs (2)

NameTypeDescription
conditioningCONDITIONINGA conditioning containing the embedded text used to guide the diffusion model.
textSTRINGThe positive prompt's text.