Earngenix Logo
Skip to main content

ComfyUI Tutorial · Beginner Friendly · 2026

ComfyUI Inpaint & Outpaint: Beginner Guide with FLUX.2 Klein

Learn how to use inpaint and outpaint in ComfyUI using the FLUX.2 Klein model. Add, remove, or replace image elements with inpaint — or expand your canvas with outpaint. Free workflows included.

By Earngenix Team14 min read
ComfyUI inpaint and outpaint guide — before and after examples using FLUX.2 Klein model

ComfyUI Inpaint & Outpaint: What They Are and When to Use Them

Quick answer: Inpaint fills or replaces a selected area inside an existing image — paint a mask, write a prompt, and AI changes only that area. Outpaint expands the canvas by generating new content beyond the original image edges. Both workflows use the FLUX.2 Klein model and run entirely on your local hardware.

Inpainting and outpainting give you precise, localized control over AI-generated images. Instead of regenerating an entire image to fix one detail or extend one side, you target exactly what needs to change. This guide covers what both techniques do, shows real before-and-after examples, and walks through the full setup and workflow steps for each.

What Is Inpaint in ComfyUI?

Inpainting fills or replaces parts of an existing image. You paint a mask over the area you want to change, write a prompt describing what should appear there, and AI regenerates only that masked region while leaving the rest of the image completely unchanged.

  • Add a missing object to a scene
  • Replace a detail — change a color, texture, or material
  • Remove an unwanted element and fill in the background naturally
  • Adjust furniture style, clothing, or small scene details

Inpaint Use Cases & Examples

Example 1 — Add a Missing Object

Adding a white ceramic mug to a desk scene where none existed.

Base image: desk without mug — before ComfyUI inpaint
Base image
Inpainted image: white ceramic mug added to desk — ComfyUI FLUX.2 Klein inpaint result
Mug added (inpainted)
Prompt useda white ceramic coffee mug with subtle reflections, realistic shadows

Example 2 — Replace a Detail

Changing a light wooden door to a dark brown door with a modern handle.

Base image: light wooden door — before ComfyUI inpaint detail replacement
Light wooden door
Inpainted image: dark brown wooden door — ComfyUI FLUX.2 Klein inpaint result
Dark brown door (inpainted)
Prompt useda dark brown wooden door with vertical panels and a modern metal handle

Example 3 — Remove an Unwanted Object

Removing a red boat from a lake scene and filling in the water naturally.

Base image: lake scene with red boat — before ComfyUI inpaint object removal
Scene with red boat
Inpainted image: red boat removed from lake — ComfyUI FLUX.2 Klein inpaint result
Boat removed (inpainted)
Prompt usedclear lake water with gentle ripples, smooth natural surface, no boats, no objects, no man-made elements, continuous reflection of pine trees and mountains, photorealistic, seamless blend with surrounding water

Example 4 — Change Furniture Style

Replacing a plain sofa with a dark green velvet sofa while keeping the rest of the room intact.

Base image: plain sofa — before ComfyUI inpaint furniture style change
Original sofa
Inpainted image: dark green velvet sofa — ComfyUI FLUX.2 Klein inpaint result
Velvet green sofa (inpainted)
Prompt useda dark green velvet sofa with plush cushions, realistic fabric texture

Inpaint Tips and Common Mistakes

  • Mask only the area you want to change. A mask that is too large will alter more of the image than intended.
  • Keep prompts short and specific. Name the object and describe its key visual properties — material, color, style.
  • If the output looks wrong, try a smaller, more precise mask or change the random seed and regenerate.
  • For object removal, describe the background that should replace the removed object — not just what is being removed.

How to Use Inpaint in ComfyUI

Step 1 — Download and Open the Workflow

Download the inpaint workflow JSON and open it in ComfyUI. If you see red nodes after importing, follow the steps below to fix them.

Step 2 — Fix Missing Nodes

If you see red nodes, open ComfyUI Manager and update ComfyUI first. This resolves most missing node issues automatically.

ComfyUI Manager — update ComfyUI to fix red missing nodes in inpaint workflow
Open ComfyUI Manager and run Update ComfyUI to fix most missing node errors.

Fix the Inpaint Crop Red Node

If the Inpaint Crop node is still red after updating, you need to install it manually via the GitHub URL below.

Open ComfyUI Manager and click Install Missing Nodes for automatic installation.

If the node is still red, click Install via Git URL in ComfyUI Manager.

Paste the GitHub URL above and click Install.

Restart ComfyUI. The red node should now be resolved.

ComfyUI Manager — install ComfyUI-Inpaint-CropAndStitch via Git URL to fix red inpaint crop node
Install the ComfyUI-Inpaint-CropAndStitch node via Git URL in ComfyUI Manager.

Fix: Security Level Configuration Error

If clicking Install via Git URL produces the following error:

This action is not allowed with this security level configuration.
ComfyUI Manager security level error — shown when trying to install via Git URL with default security settings
This error appears when the ComfyUI Manager security level blocks Git URL installs.

Open the Manager config file.

Navigate to ComfyUI_windows_portable\ComfyUI\user\__manager and open the file named config in Notepad.

Find the security_level line.

Look for the line that reads security_level = and change it to security_level = weak.

Save and restart ComfyUI.

Save the config file, restart ComfyUI, then return to Manager and install via Git URL again. Restart once more after installing.

💡 Tip: After installing all required nodes and restarting, you can change security_level back to its original value in the config file for better security.

Step 3 — Run an Inpaint Edit

Load your image in the Load Image node.

Click the Load Image node and select the image you want to edit.

ComfyUI Load Image node — selecting an image to inpaint in the inpaint workflow
Load your source image into the Load Image node.

Open the Mask Editor.

Right-click the loaded image and choose "Open in mask editor | image canvas" to open the mask painting tool.

ComfyUI mask editor opened from the Load Image node — used to paint the inpaint mask area
Right-click the image in the Load Image node to open the Mask Editor.

Paint your mask.

Use the brush to paint over the area you want to change. The white masked area is what the model will regenerate. Save the mask when done.

Video: painting a mask in the ComfyUI Mask Editor for an inpaint edit.

Add your prompt.

Write a clear, short prompt describing what should appear in the masked area. Be specific about the object, material, and style.

ComfyUI inpaint workflow — entering a text prompt to describe what should replace the masked area
Enter a clear prompt describing what the model should generate in the masked area.

Click Run.

The output will show the masked area changed according to your prompt, while the rest of the image remains exactly as it was.

💡 Tip: For the best results, use simple prompts that describe the object and its key properties. Avoid long, multi-subject prompts — ControlNet handles structure, so your prompt only needs to describe the masked area's content.

What Is Outpaint in ComfyUI?

Outpainting expands an image by generating new content beyond its original edges. You specify how many pixels to add to the left, right, top, bottom — or all sides at once — and the model fills in the new area based on your prompt and the visual context of the original image.

  • Extend a landscape by adding more sky, trees, or terrain
  • Add more room background around an architectural or interior shot
  • Reveal objects or scene elements that were outside the original frame
  • Expand a tight portrait crop to show more of the environment

Outpaint Use Cases & Examples

Example 1 — Extend a Landscape

Expanding a landscape image with additional trees and sky on the sides.

Base landscape image — before ComfyUI outpaint canvas extension
Original landscape
Outpainted landscape — canvas extended with trees and sky using ComfyUI FLUX.2 Klein
Extended landscape (outpainted)
Prompt usedextend the landscape with trees and sky

Example 2 — Add Room Background

Adding more of a room around a subject to provide wider scene context.

Base room scene — before ComfyUI outpaint background extension
Tight room crop
Outpainted room scene — background extended using ComfyUI FLUX.2 Klein outpaint workflow
Room extended (outpainted)
Prompt usedadd more of the room in the background

Example 3 — Reveal Objects Outside the Frame

Expanding the canvas to reveal additional scene elements that were cropped out of the original.

Tightly cropped scene — before ComfyUI outpaint frame expansion
Tight crop
Outpainted scene — additional elements revealed beyond original frame using ComfyUI
Frame expanded (outpainted)
Prompt usedshow more of the scene outside the frame

Example 4 — Add Context to a Portrait

Expanding a close portrait to show the surrounding environment and give the subject more visual context.

Close portrait — before ComfyUI outpaint environment expansion
Close portrait crop
Outpainted portrait with expanded background and environment — ComfyUI FLUX.2 Klein outpaint
Context added (outpainted)
Prompt usedexpand the background for a natural context

Outpaint Tips and Common Mistakes

  • Choose padding values that match your final output size. Adding too many pixels at once can make the extension look disconnected from the original.
  • If the added area looks repetitive or generic, adjust your prompt to describe specific new elements — trees, furniture, architecture — instead of just "extend the scene".
  • Try extending one side first to check how well the model matches the visual style, then extend the other sides.
  • Outpaint works best when the original image has clear visual patterns the model can follow — strong textures, defined edges, and consistent lighting.

How to Use Outpaint in ComfyUI

Download the outpaint workflow JSON and open it in ComfyUI. The same model files used for inpaint are also used for outpaint — no additional downloads needed.

Load your image.

Click the Load Images node and select the image you want to expand.

ComfyUI Load Images node — selecting a source image for the outpaint workflow
Load your source image into the Load Images node in the outpaint workflow.

Set your padding values using the ImagesPad (Kj) node.

Enter the number of pixels to add on each side — left, right, top, and bottom can be set independently. For example, add 512 to the right side to extend the image rightward.

ComfyUI ImagesPad Kj node — setting pixel padding values for outpaint canvas extension
Use the ImagesPad (Kj) node to specify how many pixels to add on each side of the image.

Add your prompt.

Write a prompt describing what should appear in the new expanded area. Mention specific elements that match the scene — not just generic descriptors.

ComfyUI outpaint workflow — entering a text prompt to describe what should appear in the expanded canvas area
Write a prompt describing the content that should fill the newly added canvas area.

Click Run and check the Save Images node.

The output image will be wider or taller depending on which sides you padded, with new content generated seamlessly from the original edges.

💡 Tip: Start with one side at a time — for example, extend only the right side first. Review the result before extending multiple sides in a single run. This makes it easier to spot and fix style mismatches early.

Troubleshooting

Quick Fixes

Red nodes after importing the workflow

Missing custom nodes or outdated ComfyUI. Open ComfyUI Manager, click Update ComfyUI, then Install Missing Nodes. For the Inpaint Crop node, see the manual install steps above using the ComfyUI-Inpaint-CropAndStitch GitHub URL.

Strange seams or visible edges after outpaint

Lower the padding amount and try extending one side at a time. Update the prompt to describe specific textures or elements that match the original image edge.

Mask not saving properly in the Mask Editor

Make sure to press Save inside the Mask Editor before closing. Confirm the mask node in the workflow displays the painted mask shape — if it appears blank, reopen and resave.

Inpainted area looks different in style from the rest of the image

Slightly reduce the inpaint strength or expand the mask slightly to include more surrounding context. A larger mask with feathered edges can help blend the edit more naturally.

Best Practices

  • Use short, specific prompts. Avoid long or vague descriptions — describe the object or area with clear material, color, and style cues.
  • Test at lower resolution first to iterate faster. Once happy with the edit, rerun at full resolution.
  • For outpaint, always generate at the native resolution of the model (FLUX.2 Klein: 1024×1024 or larger for best quality).
⚠️ Note: The FLUX.2 Klein model requires a GPU with at least 8GB VRAM for comfortable use. Running on lower VRAM may cause slow generation or out-of-memory errors. Check the ComfyUI troubleshooting guide if you run into memory errors.

Frequently Asked Questions

Inpainting in ComfyUI is a technique where you mask a specific area of an existing image and use a text prompt to replace or modify that area. The rest of the image remains unchanged. It is used to add objects, remove unwanted elements, change colors or textures, and fix image details.

Outpainting in ComfyUI expands an existing image by adding new content around the edges. You specify how many pixels to add on each side using the ImagesPad node, then write a prompt describing what should appear in the new area. It is useful for extending landscapes, adding room context, or making portrait images wider.

This workflow uses the FLUX.2 Klein 9B model. The required files are flux-2-klein-9b.safetensors (diffusion model), qwen_3_8b_fp8mixed.safetensors (text encoder), and flux2-vae.safetensors (VAE). All three files are available to download from Hugging Face.

Red nodes in the ComfyUI inpaint workflow usually mean the ComfyUI-Inpaint-CropAndStitch custom node is missing. Open ComfyUI Manager, click Install via Git URL, paste the GitHub URL for ComfyUI-Inpaint-CropAndStitch, install it, and restart ComfyUI. If you see a security level error, change the security_level setting to weak in your ComfyUI Manager config file.

Inpaint fills or replaces a selected area inside an existing image — you paint a mask over the part you want to change. Outpaint extends the image outward by adding new content beyond the original edges. Inpaint is for editing within the image; outpaint is for expanding the canvas around the image.

Discussion

Join the discussion

Sign in to leave a comment or reply

💬

No comments yet

Be the first to share your thoughts!