Nodes/JosiaNodes/Josia文本编码
ComfyUI Node

Josia文本编码

One encode node that swaps between text-to-image and image-to-image

By Josia-doit·Created 6 months ago·Updated a day ago· 16
Josia文本编码
  • clip
  • vae
  • image1
  • image2
  • image3
  • image4
  • image5
  • 正向条件
  • 负向条件
  • Latent
image_reference_switchtrue
reference_latent_modetrue
positive_prompt
negative_switchtrue
negative_prompt

JosiaEncoder (Josia文本编码) replaces the usual CLIP Text Encode + VAE Encode + Empty Latent pile with a single node that can do text-to-image, image-to-image, or reference-image-to-image depending on two switches - and it can fuse up to five reference images while it's at it. If you build workflows that flip between "generate from scratch" and "start from this image," this is the node that stops you from maintaining two separate graphs.

The four modes

Two booleans drive everything. 图像参考模式 (image reference mode) decides whether images are treated as reference input at all; 参考 Latent 模式 (reference latent mode) decides how they're used. Together they produce four behaviors, straight from the README's table:

| 图像参考模式 | 参考Latent模式 | Result | |:---:|:---:|---| | off | - | 1024×1024 empty latent, pure text conditioning (txt2img) | | off | - | empty latent at the input image's size (txt2img with image dimensions) | | on | off | VAE-encoded latent, text conditioning (standard img2img) | | on | on | VAE-encoded latent + reference-latent conditioning (reference img2img) |

The "reference latent" mode is the interesting one: it injects the image's latent into the conditioning so the model uses the original image's features, rather than just treating the VAE latent as the starting noise for a text-driven img2img. That's the difference between "redraw this picture following my prompt" and "keep this picture's structure, apply my prompt."

Inputs and outputs

Required: clip (CLIP), the two switches above, positive_prompt, negative_switch, and negative_prompt - that last switch lets you zero out negative conditioning entirely (handy for Flux-style models that don't want one). Optional: vae plus image1 through image5. The VAE is optional on purpose: leave it unplugged and img2img degrades gracefully to an empty latent instead of erroring.

Outputs: 正向条件 (positive CONDITIONING), 负向条件 (negative CONDITIONING), and Latent - the exact three wires your sampler needs, from one node. That's the whole downstream story: KSampler in, sampler out.

The source also shows the Qwen/Flux-agnostic thinking: reference images get CLIP-vision encoded and wrapped in a llama-style instruction template, which is the mechanism behind the "describe the image, then apply the user's instruction" behavior you get with image-capable models. The README notes it's built with Flux and Qwen families in mind.

Install

Zero extra Python dependencies, part of ComfyUI_JosiaNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/Josia-doit/ComfyUI_JosiaNodes

or via ComfyUI Manager (search ComfyUI_JosiaNodes), restart, and it's under Josia.

Gotchas

The reference-latent path does real CLIP-vision work and VAE encoding - it's not free compute, and five reference images means five encodings. On a low-VRAM card that's the first thing to trim when a workflow gets slow. And as with the whole pack, the UI is Chinese: you'll be flipping switches named 图像参考模式, so keep this article's table handy for the first session. One more honest note: an all-in-one like this is convenient but a little magical - if you ever need to debug exactly what's in your conditioning, the plain Text Encode + VAE Encode pair shows its work more clearly. Use the compact node when you trust the setup, not while you're debugging it.

Category⚡️JosiaNodes

Inputs (12)

NameTypeDefaultDescription
clipCLIP
image_reference_switchBOOLEANtrue
reference_latent_modeBOOLEANtrue
positive_promptSTRING
negative_switchBOOLEANtrue
negative_promptSTRING
vaeoptVAE
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
image5optIMAGE

Outputs (3)

NameTypeDescription
正向条件CONDITIONING
负向条件CONDITIONING
LatentLATENT