Nodes/ComfyUI/InpaintModelConditioning
ComfyUI Node Runs on cloud

InpaintModelConditioning

The node that makes inpainting respect the mask — and unlocks it on modern edit models

By Comfy-Org·Created 4 years ago·Updated about an hour ago· 129,962
InpaintModelConditioning
  • positive
  • negative
  • vae
  • pixels
  • mask
  • positive
  • negative
  • latent
noise_masktrue

This is the node that takes a painted mask seriously. Regular img2img sends the whole image into the latent and hopes the mask does the right thing; InpaintModelConditioning builds the conditioning so the masked region is genuinely up for grabs and the rest of the image is genuinely fixed. It's the standard "true inpainting" entry point in ComfyUI, it works across SD 1.5, SDXL, and Flux Fill, and in 2026 it's also the secret ingredient for getting modern edit models - Klein, Qwen-Image-Edit - to do masked inpainting instead of regenerating your whole frame.

How it works

Feed it positive and negative conditioning, a vae, the pixels image, and a mask. The node does three things. First, it encodes a blanked-out version of the image: the masked region is zeroed out (in normalized pixel space) before VAE encoding, so the latent contains "here's the scene, but this area is empty." That blank latent goes into the conditioning as a concat_latent_image alongside the mask, teaching the model what's outside the mask and that the inside is a hole to fill. Second, it encodes the original image as the latent you'll actually sample from. Third - and this is the noise_mask toggle, default on - it attaches a noise mask to that latent so sampling only happens inside the masked area. The tooltip's warning is worth quoting: "Might improve results or completely break things depending on the model." For most models it's the right default; some checkpoints genuinely prefer it off, so it's the first thing to flip when inpainting looks wrong.

The three outputs - positive, negative, latent - go straight into your sampler. That's the whole inpainting pipeline in one node.

The modern use

The 2026 trick that people keep rediscovering: for edit-model inpainting, use this node instead of an empty latent. The recipe from the community: InpaintModelConditioning instead of an empty latent, a Basic Scheduler so you get denoising strength back, Inpaint Crop + Stitch or at least an ImageCompositeMasked at the end, and optionally feed the inpaint image as a reference latent. That's how you get Qwen-Edit and Klein to leave the unmasked pixels alone - the thing the whole-frame editors are bad at.

How you get it

Core node, no install. It needs a VAE (the one matching your checkpoint) and works with whatever inpainting-capable model you already have in models/.

Where people get burned

Skip the composite. Encode/decode cycles degrade the whole image; paste only the inpainted pixels back with ImageCompositeMasked or crop-and-stitch, or the community's oldest rule comes back to bite you. Noise mask on the wrong model. That toggle really can break things - a model trained without mask conditioning will render noise in the masked area. Huge masks. Masking half the frame and expecting a fix is really asking for a new image; small regions at native resolution beat big regions. And if the fill looks like a blurry average of the surroundings, the blanked-pixel trick is working as designed - raise the model's ability to invent by describing the surroundings in the prompt.

Categorymodel/conditioning

Inputs (6)

NameTypeDefaultDescription
positiveCONDITIONING
negativeCONDITIONING
vaeVAE
pixelsIMAGE
maskMASK
noise_maskBOOLEANtrueAdd a noise mask to the latent so sampling will only happen within the mask. Might improve results or completely break things depending on the model.

Outputs (3)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING
latentLATENT