ArtificialGuyBR

Home / Blog / ComfyUI

ComfyUI Inpainting Workflows: A Practical Guide

A practical guide to ComfyUI inpainting workflows covering mask editing, ControlNet preservation, and masked-area sampling.

6 sources cited ComfyUI

<!-- -->

ComfyUI Inpainting Workflows: A Practical Guide

TL;DR

ComfyUI inpainting workflows span a spectrum from manual mask editing with real-time feedback to automated node pipelines that constrain generation to masked regions only. This guide covers three ComfyUI-native approaches, plus a contrasting image-to-image method from a separate platform, with practical settings and common pitfalls drawn from published community workflows.

Community-reported workflows have been verified against the published sources listed at the end of this article. Where the source material required correction, that correction is noted explicitly. Newcomers to ComfyUI should first review our ComfyUI getting started guide for installation and node basics.

How These Workflows Compare

WorkflowBest forKey advantageLimitationSource
PotatCat's XL V2 inpaintManual mask editing with visual feedbackMask opacity and colormatching controlsRequires 1:1 crop ratiocivitai.com/articles/9971
DjAfk's ControlNet OpenPosePreserving character pose during replacementUses pose data to guide replacement placementRequires OpenPose controlnet model and checkpointcivitai.com/articles/4586
EL's Inpaint-CropAndStitchFast, precise masked-only samplingSamples only the masked area, avoiding full-image passesCustom node installation requiredcivitai.com/articles/5333
MimicPC img2imgFull image transformationDALL·E 3-based creative recreationNot a ComfyUI workflow; operates on a separate platformcivitai.com/articles/6782

Mask-Based Inpainting with PotatCat's Workflow

PotatCat's XL V2 inpaint workflow recreates the A1111 inpainting experience inside ComfyUI, where a masked region is cut, regenerated, and pasted back into the original image without visible seams (civitai.com/articles/9971).

The workflow loads an image via a drag-and-drop node, then opens a mask editor accessible by right-clicking the image and selecting the mask editor option. Users draw closed shapes in the mask; the workflow fills these closed circuits to define the inpainting region. After drawing, save the mask before proceeding.

New Features

Two features added in December 2025 expand the workflow's capabilities:

Generation Settings

Use the same sampler and scheduler as the original image to reduce blending artifacts. Higher denoise values produce more change in the masked region. The workflow exposes several adjustable parameters:

The workflow outputs several views: the cut mask overlay, a before-and-after comparison of the masked area, and the full inpainted composite.

Iterative Editing

To continue inpainting from an output, copy the inpainted image to clip space via right-click, then paste it into a Load Image node. After pasting, clear the mask editor before drawing a new mask; failing to do this leaves remnants of the previous mask in the editor.

ControlNet OpenPose for Character Preservation

DjAfk published a method that uses ControlNet to maintain a character's position, size, and shape during inpainting (civitai.com/articles/4586). This approach addresses a common failure mode where the AI redraws a masked person in an unexpected location or pose.

The workflow processes the masked region to extract OpenPose skeletal data, then feeds that pose information into a ControlNet model alongside the replacement prompt. The result constrains the generated figure to match the original pose and proportions. This works with Loras and IPAdapter as additional conditioning inputs. For a complete overview of ControlNet models and their configurations, see our ControlNet in ComfyUI guide.

To run the workflow, load the checkpoint, VAE, and OpenPose controlnet into ComfyUI. The Ksampler uses a fixed seed value, which may need adjustment depending on the desired variation level. The source includes a downloadable workflow JSON file for direct import.

Inpaint-CropAndStitch: Sampling Only the Masked Area

EL's Inpaint-CropAndStitch nodes automate inpainting by restricting sampling to the masked region rather than processing the entire image (civitai.com/articles/5333, github.com/lquesada/ComfyUI-Inpaint-CropAndStitch).

The two core nodes are the "✂️ Inpaint Crop" node and the "✂️ Inpaint Stitch" node. The Crop node extracts the masked area with optional context, pre-resizes the image, extends it for outpainting, fills mask holes, grows or blurs the mask, and resizes the cropped region to a target resolution. The Stitch node reintegrates the inpainted result into the original image without altering unmasked areas, handling blending automatically.

Advantages Over Standard Inpainting

The nodes provide several benefits over full-image sampling:

  1. Speed: Sampling only the masked area is significantly faster than processing the entire image, particularly for large images with small masked regions.
  2. Context control: Users can specify the amount of surrounding image context included in the generation for more accurate prompt interpretation.
  3. Resolution management: Upscaling before sampling generates more detail, then the result is stitched back into the original. Downscaling before sampling avoids artifacts such as duplicate heads or bodies when the masked area is large relative to the image.
  4. Forced resolution: Users can enforce a specific output size (for example, 1024x1024 for SDXL models).
  5. Non-destructive editing: The unmasked portion of the image is not passed through VAE encode and decode, preserving its original quality.
  6. Automatic blending: The stitch node handles edge blending without manual intervention.

Installation is available through ComfyUI-Manager by searching for "Inpaint-CropAndStitch," or via git clone from the repository. The package is licensed under GNU General Public License Version 3 and uses code from comfy_extras, KJNodes, and Efficiency Nodes.

The repository's changelog documents active development through 2026, including GPU acceleration for 30-100x faster processing, improved stitching precision that eliminates one-pixel shifts, and a device mode option that defaults to GPU with CPU fallback for compatibility. Similar GPU optimization principles apply to ComfyUI upscaling workflows discussed elsewhere in this series.

Image-to-Image Transformation

MimicPC's img2img AI uses DALL·E 3 technology to transform uploaded images into new creations (civitai.com/articles/6782). Unlike the ComfyUI workflows above, this is a cloud-based platform rather than a local node graph. The system analyzes uploaded images for format, style, color schemes, textures, and embedded text, then recreates the image with those elements preserved.

This approach is distinct from traditional inpainting: rather than modifying a specific masked region, img2img transforms the entire image based on user-specified requirements such as style changes, object additions or removals, and compositional adjustments.

Configuration Reference

SettingRecommended ValuePurposeSource
Sampler and schedulerMatch original imageReduces blending artifacts at seamscivitai.com/articles/9971
Denoise levelHigher = more changeControls the degree of regeneration in the masked areacivitai.com/articles/9971
Pixel size / target resolution1024 for SDXL; 512 for SD 1.5Sets the generation dimensioncivitai.com/articles/5333
Mask opacity (PotatCat)Adjustable rangeControls differential diffusion mask rangecivitai.com/articles/9971
Device mode (Crop node)GPU (default); CPU fallbackSelect GPU for speed, CPU for compatibilitygithub.com/lquesada/ComfyUI-Inpaint-CropAndStitch
Mask fill threshold255, 255, 255 (#FFFFFF)Ensures fully opaque mask for correct processinggithub.com/lquesada/ComfyUI-Inpaint-CropAndStitch
Controlnet modelOpenPosePreserves skeletal pose during character replacementcivitai.com/articles/4586
Ksampler seedFixed (default)Provides consistent baseline with variation controlcivitai.com/articles/4586

Common Errors and Fixes

ProblemCauseFix
Inpainted region appears wider than expectedWorkflow forced a non-1:1 crop ratioEnsure the image can be cut as a 1:1 square; non-square crops produce distorted resultscivitai.com/articles/9971
Old mask remnants appear after pasting an inpainted imageMask editor was not cleared after pastingPress clear in the mask editor before drawing a new maskcivitai.com/articles/9971
Mask appears opaque but node treats it as transparentMask has semi-transparent pixels, not fully whiteVerify mask pixels are exactly 255, 255, 255 (RGB white); use a screenshot to check pixel valuesgithub.com/lquesada/ComfyUI-Inpaint-CropAndStitch
Double heads or bodies in inpainted outputMasked area is too large relative to the imageDownscale the cropped image before sampling using the internal_upscale_factor parametergithub.com/lquesada/ComfyUI-Inpaint-CropAndStitch
Seams visible at mask boundaryStitch mask does not blend properlyIncrease the mask_blend_pixels parameter to grow and blur the stitch boundarygithub.com/lquesada/ComfyUI-Inpaint-CropAndStitch

FAQ

What are the key differences between ComfyUI inpainting and traditional full-image sampling? ComfyUI inpainting workflows that use masked-area sampling, such as Inpaint-CropAndStitch, restrict the diffusion process to the masked region only. This avoids unnecessary computation on unmasked areas, reduces inference time, and prevents artifacts that occur when the full image passes through the VAE encode-decode cycle (civitai.com/articles/5333, github.com/lquesada/ComfyUI-Inpaint-CropAndStitch).

How do you continue inpainting from an already inpainted image in ComfyUI? Copy the inpainted image to clip space via right-click, then paste it into a Load Image node. After pasting, clear the mask editor before drawing a new mask; otherwise remnants of the previous mask persist (civitai.com/articles/9971).

How effective is ControlNet for maintaining character position during inpainting? The OpenPose-based ControlNet approach processes the masked region to extract skeletal pose data, then uses that data to constrain the replacement figure's position, size, and shape. This is particularly useful when masking a person or multiple people and wanting the generated figure to occupy the same position (civitai.com/articles/4586).

What are the advantages of using Inpaint-CropAndStitch nodes over standard inpainting? The nodes sample only the masked area rather than the full image, which is significantly faster. They also allow forced resolution, context window control, automatic blending, and protection of unmasked areas from VAE processing (civitai.com/articles/5333, github.com/lquesada/ComfyUI-Inpaint-CropAndStitch).

How does differential diffusion improve mask blending in ComfyUI? PotatCat's workflow leverages differential diffusion to use the full mask range with adjustable opacity rather than relying solely on denoise tweaking. This provides a direct control surface for how much of the mask transitions from inpainted to original (civitai.com/articles/9971).

What file formats does img2img AI support for input and output? Img2img AI supports a wide range of formats including JPEG, PNG, GIF, BMP, and TIFF. The MimicPC platform processes images through a browser interface, making it compatible with most modern devices (civitai.com/articles/6782).

Where can I download the Inpaint-CropAndStitch example workflows? The repository at github.com/lquesada/ComfyUI-Inpaint-CropAndStitch includes four example workflow JSON files: inpaint_sd15.json, inpaint_hires.json, inpaint_flux.json, and inpaint-cropandstitch_example_workflow_context_mask.json, each demonstrating a different configuration (github.com/lquesada/ComfyUI-Inpaint-CropAndStitch).

Sources

SourceContributionURL
PotatCat's XL V2 inpaint workflowMask-based inpainting guide with new opacity and colormatching featureshttps://civitai.com/articles/9971
DjAfk's ControlNet OpenPose inpaintingMethod for preserving character pose using pose data and ControlNethttps://civitai.com/articles/4586
EL's Inpaint-CropAndStitch tutorialNodes for masked-only sampling with resolution control and upscaling/downscalinghttps://civitai.com/articles/5333
MimicPC img2img AI tutorialDALL·E 3-based image transformation platform and guidehttps://civitai.com/articles/6782
ComfyUI-Inpaint-CropAndStitch repositoryPrimary source code, documentation, and examples for the Crop and Stitch nodeshttps://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch
ComfyUI repositoryOfficial ComfyUI framework and custom node infrastructurehttps://github.com/comfyanonymous/ComfyUI