Skip to content
,

ComfyUI Inpainting Guide (2026): Masks, Nodes, Flux Fill and Fixes

8–12 minutes
Surprised woman in a hijab and green sweater by a night city window holding an INPAINT card, with the hook Repaint any part of any image

Inpainting lets you repaint just one part of an image and leave the rest alone. You can remove a stray object, change a shirt colour, fix a messed-up hand, swap a sky or add something that was never there.

In ComfyUI it comes down to three things: an image, a mask that marks the area to change, and a model that fills that area so it blends with everything around it.

This guide covers the official basic inpainting workflow, how to draw masks in the Mask Editor, the two inpainting nodes and when to use each, the Flux.1 Fill dev method for the best quality, the settings that matter, and how to fix the usual problems. Steps follow the official ComfyUI docs as of November 2026.

TL;DR

  • Quick start: download 512-inpainting-ema.safetensors into ComfyUI/models/checkpoints/, load the official SD inpaint workflow, upload an image and press Run.
  • Mask: right-click Load Image > Open in MaskEditor, paint over the area, click Save.
  • Two nodes: VAE Encode (for Inpainting) for classic SD inpainting (denoise 1.0), InpaintModelConditioning for Flux Fill and partial-denoise edits.
  • grow_mask_by: default 6. Raise it to 10 to 16 if you see hard seams.
  • Best quality: Flux.1 Fill dev (flux1-fill-dev.safetensors in models/diffusion_models/).
  • Prompt only what goes in the mask, not the whole picture.

How Inpainting Works

A normal text-to-image run starts from pure noise. Inpainting starts from your picture instead. The mask tells ComfyUI which pixels it may change.

Inside the mask, the model generates new content from your prompt. Outside the mask, the original pixels are kept. The model also looks at the surrounding area, so lighting, perspective and texture match.

Piece Job
Image The picture you want to fix or change
Mask White (painted) area = change it, everything else = keep it
Prompt Describes what should appear inside the mask
Inpainting node Combines image, mask and VAE into a latent the sampler can work on
Model Fills the masked area. Dedicated inpainting models blend best

Inpainting is closely related to outpainting, which extends an image beyond its borders, and to image to image, which repaints the whole picture at a chosen strength.

Which Model to Use

Model File and folder Best for VRAM
SD 2 inpainting (official tutorial) 512-inpainting-ema.safetensors in models/checkpoints/ Learning, quick fixes, low VRAM Low
Flux.1 Fill dev flux1-fill-dev.safetensors in models/diffusion_models/ Realistic edits, best blending and prompt following High (fp8 or GGUF to save memory)
Any regular checkpoint (SD 1.5, SDXL) Your usual checkpoint Small edits in the same style as your image Low to medium
Qwen-Image Edit and similar edit models See our guides Edits by instruction without a mask High

The official tutorial compares the inpainting model against the standard v1-5-pruned-emaonly-fp16.safetensors and notes that the inpainting model gives better results and more natural transitions, because it was trained for exactly this job.

Not sure where a file goes? Our ComfyUI model folders cheat sheet lists every folder.

Method 1: The Official Basic Workflow

  1. Update ComfyUI so you have the current nodes and templates. See our ComfyUI update guide. New users can start with how to install ComfyUI.
  2. Download the model 512-inpainting-ema.safetensors from the Comfy-Org stable_diffusion_2.1_repackaged page on Hugging Face and put it in ComfyUI/models/checkpoints/.
  3. Load the workflow. Download the official sd1.5_inpaint.png workflow image from the Comfy-Org example_workflows repo and drag it onto the canvas, or open it with Workflows > Open (Ctrl + O).
  4. Check Load Checkpoint is set to 512-inpainting-ema.safetensors.
  5. Upload your image to the Load Image node. The tutorial’s sample image already has a transparent area, and that transparent area is treated as the mask.
  6. Write a prompt for what should appear in the masked area, plus a negative prompt.
  7. Click Run or press Ctrl + Enter.
  8. Try other seeds in the KSampler until you get a result you like.

The nodes in this workflow are: Load Checkpoint, Load Image, two text prompt nodes, VAE Encode (for Inpainting), KSampler, VAE Decode and Save Image.

Draw a Mask in the Mask Editor

For your own images you will usually paint the mask yourself.

  1. Upload the image to Load Image.
  2. Right-click the Load Image node and choose Open in MaskEditor.
  3. Set the brush size, opacity and hardness in the panel on the right.
  4. Paint over the area you want to change. Go slightly past the edges of the object.
  5. Use the eraser to fix mistakes.
  6. Click Save. The mask now flows from the node’s MASK output into the inpainting node.

Re-inpaint a result: right-click Save Image and choose Copy (Clipspace), then right-click Load Image and choose Paste (Clipspace). Open the Mask Editor again and paint the next area. This is how you fix an image one piece at a time.

Mask tip Why
Cover the whole object plus a small margin Leftover edges of the old object show through otherwise
Include the shadow when removing an object A floating shadow is a giveaway
Keep masks reasonably sized A tiny mask gives the model no room to draw something new
Use a soft brush for organic shapes Softer edges blend better on skin, hair and skies

Need a precise mask around a person or product? A background removal model can make one automatically. See how to remove backgrounds locally.

VAE Encode for Inpainting vs InpaintModelConditioning

ComfyUI has two built-in ways to feed an inpainting job to the sampler.

VAE Encode (for Inpainting) InpaintModelConditioning
Inputs pixels, vae, mask, grow_mask_by positive, negative, vae, pixels, mask (current builds also have a noise_mask toggle)
Outputs latent positive, negative, latent
What it does Blanks the masked area before encoding, so the model must invent it from scratch Passes the original image and mask to the model as conditioning, and keeps the original pixels in the latent
Denoise Must be 1.0 Works at 1.0 or lower, so you can make subtle changes
Best with SD 1.5 and SD 2 inpainting checkpoints Flux.1 Fill dev and inpainting models where you want to keep some of the original

Simple rule: to replace something completely, either node works. To change something gently (recolour a shirt, refine a face), use InpaintModelConditioning with a denoise around 0.5 to 0.8, because VAE Encode (for Inpainting) throws away the original pixels under the mask.

Method 2: Flux.1 Fill Dev Inpainting

Flux.1 Fill dev is Black Forest Labs’ dedicated fill model. It understands the scene around the mask very well and follows prompts closely, so it is the best choice for realistic edits if your GPU can handle it.

Files you need

The model is gated: open black-forest-labs/FLUX.1-Fill-dev on Hugging Face, sign in and accept the licence first.

File Folder
flux1-fill-dev.safetensors ComfyUI/models/diffusion_models/
clip_l.safetensors ComfyUI/models/text_encoders/
t5xxl_fp16.safetensors (or t5xxl_fp8_e4m3fn for less VRAM) ComfyUI/models/text_encoders/
ae.safetensors ComfyUI/models/vae/

If you already run Flux text-to-image, you only need the fill model. Our how to use Flux guide covers the shared files.

Steps

  1. Open Workflow > Browse Templates and search for Flux Fill. Pick the Flux.1 Fill dev inpaint template.
  2. Check the loaders: Load Diffusion Model = flux1-fill-dev.safetensors, DualCLIPLoader = t5xxl + clip_l with type flux, Load VAE = ae.safetensors.
  3. Upload your image and paint the mask in the Mask Editor.
  4. Describe what should appear in the masked area.
  5. Click Run.

The template routes the image and mask through InpaintModelConditioning and uses a high FluxGuidance value. That high value is normal for the Fill model, so leave it unless you have a reason to change it.

Inpainting With a Regular Model

You do not have to use a dedicated inpainting checkpoint. A regular SD 1.5 or SDXL model keeps the same style as images it generated.

  • For a complete replacement, use VAE Encode (for Inpainting) at denoise 1.0 and a generous grow_mask_by so the seam blends.
  • For a light touch-up, encode the image with a normal VAE Encode, add the mask with Set Latent Noise Mask, and use a denoise of 0.4 to 0.7.
  • Expect weaker blending than a dedicated inpainting model, especially on large masks.

Want to keep a pose or outline while repainting? Combine the mask with a ControlNet. See our ComfyUI ControlNet guide.

Settings That Matter

Setting Where Starting value Effect
grow_mask_by VAE Encode (for Inpainting) 6 (default), range 0 to 64 Expands the mask outward so the edge blends. 10 to 16 for softer transitions
denoise KSampler 1.0 to replace, 0.5 to 0.8 to adjust How much the masked area changes
steps KSampler 20 to 30 More steps can add detail
cfg KSampler Model default (around 7 for SD) Higher follows the prompt harder but can look harsh
seed KSampler Randomize Try several seeds; inpainting results vary a lot
Prompt Text encode Describe the masked area only Prompting the whole scene can paint extra objects into the mask

Recipes for Common Jobs

Job Mask Prompt idea Settings
Remove an object Object plus its shadow Describe the background, e.g. “empty wooden table” Denoise 1.0, grow_mask_by 10+
Change clothing colour The garment “red knitted sweater” InpaintModelConditioning, denoise 0.6 to 0.8
Replace the sky Sky area “dramatic sunset sky, orange clouds” Denoise 1.0, soft brush
Fix a hand The whole hand “natural hand, five fingers, relaxed” Denoise 0.7 to 1.0, several seeds
Add an object Where it should go, a bit larger than the object “a ceramic coffee mug” Flux Fill works best
Fix faces automatically Detected by a model Your normal prompt Use a FaceDetailer node

For removing objects with an edit model and no hand-painted prompt, try our Qwen-Image remove object LoRA workflow.

Troubleshooting

Problem Likely cause Fix
Nothing changes Mask not saved, or denoise too low Save in the Mask Editor and check the MASK wire; raise denoise
Grey or blurry blob in the mask Regular model with VAE Encode (for Inpainting) Use an inpainting model, or switch to Set Latent Noise Mask
Visible seam or halo grow_mask_by too small, hard mask edge Raise grow_mask_by, paint with a softer brush
Old object still visible Mask too tight Paint past the edges and include the shadow
Wrong thing appears in the mask Prompt describes the whole scene Describe only what should fill the mask
Colours shift outside the mask Repeated VAE encode/decode Composite the result back onto the original with the mask
Flux Fill out of memory Model too big for your GPU Use the fp8 text encoder or a GGUF fill model
Still stuck Many possible causes See our ComfyUI inpainting not working fix

FAQ

Do I need a special model for inpainting in ComfyUI?

No, but it helps a lot. Dedicated inpainting models such as 512-inpainting-ema.safetensors or Flux.1 Fill dev blend much better than regular checkpoints.

What does grow_mask_by do?

It expands your mask outward by that many pixels so the model can repaint a thin border of the original and hide the seam. The default is 6.

What denoise should I use for inpainting?

Use 1.0 to replace something completely. Use 0.5 to 0.8 with InpaintModelConditioning or Set Latent Noise Mask when you want to keep part of the original.

How do I open the Mask Editor?

Right-click the Load Image node and choose Open in MaskEditor. Paint, then click Save.

Is Flux Fill free to use?

You can download it free after accepting the licence on Hugging Face. FLUX.1 dev models use a non-commercial licence, so check the terms before using outputs commercially.

Can I inpaint the same image several times?

Yes. Copy the result with Copy (Clipspace) from Save Image, paste it into Load Image with Paste (Clipspace), and mask the next area.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Surprised woman in a hijab and green sweater by a night city window holding an INPAINT card, with the hook Repaint any part of any image