Image ToolsIntermediate

How to Inpaint and Fix Part of an Image in ComfyUI

Use the mask editor and an inpaint workflow to repaint a specific region, like fixing a hand or removing an object, without touching the rest.

8 minIntermediate

Inpainting lets you change only a masked part of an image while keeping everything else. It is how you fix a broken hand, swap a background object, or remove an unwanted element. ComfyUI has a built-in mask editor plus dedicated inpaint nodes that make this reliable.

What you need

  • An image to edit (generated or imported)
  • A checkpoint; an inpainting-specialized checkpoint works best but a normal one is fine
  • A few minutes to paint the mask

Step 1: Load the image

Add a Load Image node and select your file, or drag the image straight onto the node. If you want to edit something you just generated, save it first, then load it back in.

Step 2: Paint the mask

Right-click the Load Image node and choose Open in MaskEditor. Paint over the region you want to change with the brush, adjust the brush size as needed, then click Save to node. The painted area becomes the mask.

ComfyUI - MaskEditor
MaskEditor [ Save to node ]
----------------------------------------------------
+------------------------------+ Brush size: 42
| image preview | Opacity: 0.7
| (////) <- painted |
| mask region |
+------------------------------+
The painted overlay marks exactly what the model is allowed to repaint.

Step 3: Encode for inpainting

Add a VAE Encode (for Inpainting) node. Feed it the image, the mask, and your VAE. This produces a latent that tells the sampler which pixels are locked and which are free to change.

Step 4: Prompt for only the masked area

Your positive prompt should describe what you want in the masked region, in the context of the whole scene. To remove an object, describe what should be there instead, for example the wall or sky behind it. Connect the encoded latent into a KSampler.

Denoise controls how much changes
Set the KSampler denoise around 0.8 to 1.0 to fully repaint the masked area. Lower values keep more of the original and are useful for subtle touch-ups rather than full replacements.

Step 5: Decode, check, repeat

Run a VAE Decode and Save Image. If the seam shows or the fix is not quite right, change the seed or grow the mask slightly and queue again. Inpainting is iterative, so expect a few attempts.

example inpaint prompt (remove a sign)
a clean red brick wall, even lighting, matching the surrounding texture

Result: a targeted edit that blends with the original image. The unmasked pixels stay byte-for-byte the same, so only your chosen region changes.

Watch related tutorials

Tags
#inpainting#comfyui#mask#editing