Inpainting VAE Encode (WAS)
The core inpaint encode, plus a mask-offset knob
- pixels
- vae
- mask
- LATENT
ComfyUI already ships a "VAE Encode (for Inpainting)" node, so the first question is why this one exists. The answer is one extra dial: mask_offset. This WAS version does the same job - encode an image plus a mask into a latent with a noise_mask attached - but lets you grow or shrink the mask before it ever touches the encoder, which is the difference between a clean inpaint and one with a visible seam.
How it works
The mechanic is standard masked-latent inpainting: the mask gets resized to match your image, applied to the pixels, and the whole thing gets VAE-encoded into a latent that carries a noise_mask alongside it. Whatever's under the white part of the mask is what your sampler is allowed to touch; the black part is locked. Where this node earns its keep is mask_offset - a positive value dilates (expands) the mask, a negative value erodes (shrinks) it, before encoding. Painting a mask that hugs the object too tightly tends to leave a visible ring where old and new content meet; nudging the offset a few pixels positive gives the model some buffer around the edge to blend into, which is exactly the boundary-artifact problem this node was built to reduce.
Worth knowing going in: encoding the masked region to latent noise like this generally wants a denoise of 1.0 downstream - you're regenerating the masked area from scratch, not lightly touching it up. If you want to inpaint at a lower denoise while keeping some of the original content as a hint, that's a job for InpaintModelConditioning instead, which core ComfyUI added specifically to handle the "keep original content, partial denoise" case that plain VAE-encode-for-inpaint can't do cleanly.
The inputs and outputs that matter
pixels(IMAGE) - the image you're inpainting.vae(VAE) - the VAE to encode with; match it to whatever checkpoint you're sampling with.mask(MASK) - white = paint here, black = leave alone.mask_offset(default 6, range -128 to 128) - the one setting you'll actually tune. Positive dilates the mask (bigger buffer, softer blend, safer against leftover halos); negative erodes it (tighter to your painted region, less risk of eating into detail you wanted to keep). The default of 6 is a mild dilate, which is a reasonable starting point for most masks.
Single output: LATENT, ready to feed straight into a KSampler alongside your usual positive/negative conditioning.
How to install it
Via ComfyUI Manager: search "WAS_Extras", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/WAS_Extras
Restart ComfyUI. No extra Python dependencies for this particular node - the pack's requirements.txt is only needed for the ksampler_sequence.py nodes (the CLIP Text Encode Sequence / KSampler Sequence family), not this one.
Common issues & troubleshooting
Results look muddy or washed out at the seam. That's the classic sign of too little mask buffer. Bump mask_offset up a few units before touching anything else - it's cheaper than fighting it with denoise or CFG.
The inpaint isn't taking at all, or looks like a no-op. Check your downstream KSampler's denoise. This node's noise_mask is built for a full 1.0 denoise on the masked region; a low denoise here will barely touch the mask and you'll wonder why nothing changed.
Fine detail you wanted to keep got erased. You probably over-dilated. Pull mask_offset toward zero, or negative, to tighten the mask back down to what you actually painted.
Need partial-denoise inpainting that respects the original pixels underneath. This node isn't the tool for that - reach for core ComfyUI's InpaintModelConditioning node instead, which was built precisely so you can inpaint at less than full denoise without the masked region collapsing to pure noise first.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | Input image to encode for inpainting. | |
| vae | VAE | VAE module used to encode the image. | |
| mask | MASK | Inpaint mask; white=painted region, black=protected. | |
| mask_offset | INT | 6-128–128 | Positive expands mask (dilate), negative shrinks (erode). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |