ComfyUI Inpainting Workflows: A Practical Guide
A practical guide to ComfyUI inpainting workflows covering mask editing, ControlNet preservation, and masked-area sampling.
On this page
<!-- -->
- Use PotatCat's XL V2 workflow for guided mask editing with opacity control and color matching
- Apply ControlNet OpenPose to preserve character position and shape when replacing masked regions
- Install Inpaint-CropAndStitch nodes to reduce sampling time and enforce target resolution
ComfyUI Inpainting Workflows: A Practical Guide
TL;DR
- Use PotatCat's XL V2 mask editor with opacity and colormatching for guided, visible inpainting
- Preserve character position during replacement with DjAfk's ControlNet OpenPose workflow
- Speed up generation by sampling only masked regions using Inpaint-CropAndStitch nodes
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
| Workflow | Best for | Key advantage | Limitation | Source |
|---|---|---|---|---|
| PotatCat's XL V2 inpaint | Manual mask editing with visual feedback | Mask opacity and colormatching controls | Requires 1:1 crop ratio | civitai.com/articles/9971 |
| DjAfk's ControlNet OpenPose | Preserving character pose during replacement | Uses pose data to guide replacement placement | Requires OpenPose controlnet model and checkpoint | civitai.com/articles/4586 |
| EL's Inpaint-CropAndStitch | Fast, precise masked-only sampling | Samples only the masked area, avoiding full-image passes | Custom node installation required | civitai.com/articles/5333 |
| MimicPC img2img | Full image transformation | DALL·E 3-based creative recreation | Not a ComfyUI workflow; operates on a separate platform | civitai.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:
- Mask opacity allows adjusting the mask's transparency, which pairs with differential diffusion to use the full mask range for finer control than adjusting denoise alone.
- Colormatching addresses color shifts that occur when the VAE encodes and decodes the image, helping the inpainted region blend with the original's color profile.
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:
- Pixel size sets the generation resolution (1024 produces 1024x1024).
- Expand mask controls how far the mask grows from its original boundary.
- Padding defines the unprocessed area surrounding the mask that still participates in generation.
- Mask blur radius adjusts the softness of the mask edge.
- Fill mask holes enables automatic filling of fully enclosed mask regions.
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:
- Speed: Sampling only the masked area is significantly faster than processing the entire image, particularly for large images with small masked regions.
- Context control: Users can specify the amount of surrounding image context included in the generation for more accurate prompt interpretation.
- 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.
- Forced resolution: Users can enforce a specific output size (for example, 1024x1024 for SDXL models).
- Non-destructive editing: The unmasked portion of the image is not passed through VAE encode and decode, preserving its original quality.
- 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
| Setting | Recommended Value | Purpose | Source |
|---|---|---|---|
| Sampler and scheduler | Match original image | Reduces blending artifacts at seams | civitai.com/articles/9971 |
| Denoise level | Higher = more change | Controls the degree of regeneration in the masked area | civitai.com/articles/9971 |
| Pixel size / target resolution | 1024 for SDXL; 512 for SD 1.5 | Sets the generation dimension | civitai.com/articles/5333 |
| Mask opacity (PotatCat) | Adjustable range | Controls differential diffusion mask range | civitai.com/articles/9971 |
| Device mode (Crop node) | GPU (default); CPU fallback | Select GPU for speed, CPU for compatibility | github.com/lquesada/ComfyUI-Inpaint-CropAndStitch |
| Mask fill threshold | 255, 255, 255 (#FFFFFF) | Ensures fully opaque mask for correct processing | github.com/lquesada/ComfyUI-Inpaint-CropAndStitch |
| Controlnet model | OpenPose | Preserves skeletal pose during character replacement | civitai.com/articles/4586 |
| Ksampler seed | Fixed (default) | Provides consistent baseline with variation control | civitai.com/articles/4586 |
Common Errors and Fixes
| Problem | Cause | Fix | |
|---|---|---|---|
| Inpainted region appears wider than expected | Workflow forced a non-1:1 crop ratio | Ensure the image can be cut as a 1:1 square; non-square crops produce distorted results | civitai.com/articles/9971 |
| Old mask remnants appear after pasting an inpainted image | Mask editor was not cleared after pasting | Press clear in the mask editor before drawing a new mask | civitai.com/articles/9971 |
| Mask appears opaque but node treats it as transparent | Mask has semi-transparent pixels, not fully white | Verify mask pixels are exactly 255, 255, 255 (RGB white); use a screenshot to check pixel values | github.com/lquesada/ComfyUI-Inpaint-CropAndStitch |
| Double heads or bodies in inpainted output | Masked area is too large relative to the image | Downscale the cropped image before sampling using the internal_upscale_factor parameter | github.com/lquesada/ComfyUI-Inpaint-CropAndStitch |
| Seams visible at mask boundary | Stitch mask does not blend properly | Increase the mask_blend_pixels parameter to grow and blur the stitch boundary | github.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
| Source | Contribution | URL |
|---|---|---|
| PotatCat's XL V2 inpaint workflow | Mask-based inpainting guide with new opacity and colormatching features | https://civitai.com/articles/9971 |
| DjAfk's ControlNet OpenPose inpainting | Method for preserving character pose using pose data and ControlNet | https://civitai.com/articles/4586 |
| EL's Inpaint-CropAndStitch tutorial | Nodes for masked-only sampling with resolution control and upscaling/downscaling | https://civitai.com/articles/5333 |
| MimicPC img2img AI tutorial | DALL·E 3-based image transformation platform and guide | https://civitai.com/articles/6782 |
| ComfyUI-Inpaint-CropAndStitch repository | Primary source code, documentation, and examples for the Crop and Stitch nodes | https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch |
| ComfyUI repository | Official ComfyUI framework and custom node infrastructure | https://github.com/comfyanonymous/ComfyUI |