Nodes/ComfyUI-Image-Inpainting/VAE Decode Inpaint
ComfyUI Node

VAE Decode Inpaint

The decode half of the pair — back to pixels, right-sized

By SherryXieYuchen·Created 2 years ago·Updated 2 years ago· 4
VAE Decode Inpaint
  • samples
  • vae
  • pixels
  • IMAGE

"VAE Decode Inpaint" is the counterpart to VAE Encode Inpaint: where the encode side padded your image up to a VAE-friendly size and stuffed a noise mask into the latent, this node takes the sampled LATENT and decodes it back to pixels - then crops the padding back off so you get exactly the image you started with, not a slightly larger one with a gray border.

In the bundled workflow it sits right after the KSampler: VAEEncode → KSampler → VAEDecode, with the decoded output feeding ColorCorrection Inpaint and then ImagePostprocess before the region gets composited back. If you've only ever used ComfyUI's stock VAEDecode, this node's job is basically "the same thing, but it remembers what size your image actually was."

How it works

Three required inputs: samples (the latent from your sampler), vae, and pixels (the original image). That third input is the important one - it's how the node knows the true dimensions. The decode runs, then the result is cropped back to the pixel dimensions of the pixels input using the same centered-offset math the encode node used to pad. Nothing clever, just symmetry: whatever VAEEncode Inpaint padded, this unpads.

Output is a plain IMAGE, ready to be color-corrected, composited, or saved.

The pair exists because a naive encode/decode cycle is exactly what the inpainting community learned to avoid - running the whole frame through the VAE twice shifts colors and blurs unmasked regions, which is why the KB's essay on inpainting hammers "composite after inpainting." These two nodes don't break that rule by magic; they just make sure the padding bookkeeping doesn't force you to re-encode the whole frame to fix it. The unmasked pixels are only safe because the sampler (via the noise mask from VAEEncode) never touched them.

Install

Standard pack install - Manager → search "ComfyUI-Image-Inpainting", or:

cd ComfyUI/custom_nodes
git clone https://github.com/SherryXieYuchen/ComfyUI-Image-Inpainting
# restart ComfyUI

Needs a VAE, nothing else. Use the same VAE you encoded with - mixing VAEs between encode and decode is a reliable way to get muddy colors, and since the whole point of this node is color fidelity, don't sabotage it.

The one gotcha

pixels should be the same image you fed to VAEEncode. Feed it a differently-sized image and the crop math will truncate or pad in the wrong place and you'll get a shifted, partial result. The bundled workflow routes the same preprocessed image into both, and you should too.

Categorylatent

Inputs (3)

NameTypeDefaultDescription
samplesLATENT
vaeVAE
pixelsIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE