Skip to content

FLUX.1 Fill: Inpainting and Outpainting ​

FLUX.1 Fill is the image-completion-focused model in Black Forest Labs' FLUX.1 Tools suite: give it an image plus a mask, and it only fills in the part enclosed by the mask, keeping pixels outside the mask exactly as they are. The team states that its inpainting and outpainting quality is second only to the commercial FLUX.1 Fill [pro].

This page walks you through two operations using the official templates: inpainting — change only what the mask encloses, fixing flaws and swapping local elements; outpainting — extend the image beyond its boundaries, turning a square image into a landscape one. This is also one of the standard approaches to ComfyUI inpainting: define the area, edit precisely, and leave everything outside untouched.

What You'll Be Able to Do After This Lesson ​

  • Run the official FLUX.1 Fill workflow: template loading → four-file setup → masked inpainting output
  • Do masked inpainting: change only what's inside the mask, with not a single pixel outside it altered
  • Outpaint with Pad Image for Outpainting: four-side parameters control the expansion direction, turning a square image into a landscape one
  • Understand the inpainting-specific node InpaintModelConditioning: where the image and mask merge, and what the noise_mask toggle controls
  • Remember the Fill iron rules: cfg 1, 20 steps, euler/normal, guidance 30

Your Current Pain Points ​

  • You're 95% happy with an image, but one corner has a flaw — regenerate, and the other 95% all changes
  • Forcing edits with img2img: crank the denoise up and the whole image drifts; keep it low and that one spot won't budge
  • You want to expand a portrait image into a landscape for a cover, but direct stretching distorts it, and cropping cuts out the subject

When to Use This Technique ​

When you need to:

  • Change only a small part of the image: remove a passerby, fix an extra finger, or change a character's outfit
  • Enlarge the canvas: extend the scene outward, turn a square image into a landscape, or fill in compositional whitespace
  • Keep everything outside the mask strictly unchanged — pixel-perfect outside the mask

And you don't want to:

  • Re-roll the entire image for one small flaw
  • Edit the whole image with a one-sentence instruction — that's the job of the previous lesson Kontext, which edits based on its understanding of the instruction and doesn't guarantee pixels outside the area stay untouched

🎒 Preparation Before Starting ​

  • You've completed FLUX.1 text-to-image: the four-file directory conventions, cfg 1, and other FLUX-family common knowledge are covered in that lesson
  • You can load templates, upload images, and run with Ctrl+Enter (if you forgot, review your first generation)
  • Reserve about 31.8GB of disk space: diffusion model 22.17GB + t5xxl_fp16 9.12GB + clip_l 234.7MB + VAE 319.8MB (if you've installed the full FLUX.1 text-to-image setup, you can reuse the last three and only need to download the diffusion model)
  • ComfyUI updated to a fairly recent version: the inpainting template uses the subgraph feature, the template library metadata requires 0.3.42 or above, and the template note also reminds you to update ComfyUI first
  • Your network can reach Hugging Face; if the connection is unstable, use the ModelScope domestic mirror (address given in Step 2)
  • Prepare an image to edit — a portrait, product photo, or illustration all work; to align with the official examples, download the official inpainting sample image (mask included) or the official outpainting sample image
  • A cup of water ☕ — downloading the 22GB model is the biggest wait in this lesson

Core Idea ​

Inpainting solves the pain point of re-rolling an entire image for one small flaw. The official basic tutorial has a vivid analogy: when the overall image is satisfying but a few elements are wrong, regenerating gives you a completely different image — so let the painter (the model) repaint only the area you've marked out. FLUX.1 Fill was trained specifically for this task: input = the original image outside the mask + the mask, output = the completed full image. The official basic tutorial also reveals the essence of outpainting: outpainting is really just an inpainting workflow, only with different nodes used to build the mask.

Put the three ways of editing an image side by side:

MethodScope of ChangePixels Outside the MaskTypical Scenarios
Regeneration / image-to-imageEntire imageNot guaranteedRe-rolling composition, changing style
Kontext (previous lesson)Edits by instruction, understood across the whole imageHighly consistent, but no promise of pixel-level identityChange the background or outfit in one sentence
FLUX.1 Fill (this lesson)Inside the maskStrictly preserved, nothing movesPrecisely fix one corner, expand the canvas

Where do the image and the mask converge? Look at the data flow of the inpainting template (prompt and model chain omitted; step 4 covers it node by node):

Load Image ─┬→ IMAGE ─→ InpaintModelConditioning ─┬→ positive ──┐
            └→ MASK ──→ (original image + mask encoded into the condition)      ├→ negative ──┼→ KSampler ─→ VAEDecode ─→ Save Image
                                                └→ latent ────┘      ↑
CLIPTextEncode (positive prompt)─→ FluxGuidance ───────────────────────────┤
UNETLoader(flux1-fill-dev)─→ DifferentialDiffusion ─────────────────┘

The core is InpaintModelConditioning: it encodes "the original image outside the mask + the mask" into the input format that FLUX.1 Fill was trained to recognize and attaches it to the condition, while also encoding the original image as the starting latent. It also has a noise_mask switch (per the node source code description: adds a noise mask to the latent so sampling only happens inside the mask; results vary by model):

noise_maskSampling rangeUsed in
true(inpainting template)Samples only inside the mask; pixels outside stay untouchedLocal inpainting
false(outpainting template)The whole new canvas participates in denoisingOutpainting — Fill references the original image to keep the non-expanded region consistent and fills in the new gray area

Difference from traditional SD inpainting: the basic inpainting tutorial uses the VAE Encode (for Inpainting) node (relying on grow_mask_by to grow the mask edge); inpainting-specific models like FLUX.1 Fill instead use InpaintModelConditioning, feeding the masked image directly to a model trained for exactly this — which is also why it holds the area outside the mask more reliably.

Follow along ​

Step 1: Load the official FLUX.1 Fill workflow template ​

Why: The official template comes with parameters, model download links, and a sample image all set up — you only need to swap in your own image and prompt to run it.

How: Open the template library from Templates in the left sidebar, search for Flux.1, and pick "Flux.1 Image Inpainting" (template ID flux_fill_inpaint_example; the official docs give "Flux.1 Inpaint" as the search term). Run this one first; we'll switch to the outpainting template in step 5. If you'd rather not use the template library, download the JSON and open it via the menu Workflows → Open (Ctrl+O): flux_fill_inpaint_example.json. For the full guide to the template library, see template library.

You should see: a compact three-node structure on the canvas — Load Image (referencing the official sample image flux_fill_inpaint_example_input_image.png) → a subgraph node named Flux.1 Fill Dev Image Inpainting → Save Image. The subgraph node directly exposes image, mask, prompt, seed, and four model file dropdowns on its surface; a sticky note next to it is filled with model download links. Note that both the IMAGE and MASK wires from Load Image connect into the subgraph — MASK is the work area you circled.

  • Template loaded successfully, with the subgraph node and the model-link sticky note visible

Step 2: Download the four Fill files and put them in place ​

Why: Fill is a separately trained inpainting model — it, the text-to-image flux1-dev, and the instruction-editing flux1-dev-kontext are three files that are not interchangeable; each of the four files must go to its place for the loader's dropdown lists to find them.

How: Download the four files from Hugging Face (the template's sticky note has all the links):

FileSizeWhich subdirectory to put it inDownload
flux1-fill-dev.safetensors22.17 GBmodels/diffusion_models/Hugging Face · ModelScope mirror
clip_l.safetensors234.7 MBmodels/text_encoders/Hugging Face
t5xxl_fp16.safetensors9.12 GBmodels/text_encoders/Hugging Face
ae.safetensors319.8 MBmodels/vae/Hugging Face · ModelScope mirror

The directory structure looks like this:

ComfyUI/
├── models/
│   ├── diffusion_models/
│   │   └── flux1-fill-dev.safetensors
│   ├── text_encoders/
│   │   ├── clip_l.safetensors
│   │   └── t5xxl_fp16.safetensors
│   └── vae/
│       └── ae.safetensors

💡 Can the files from the previous lesson be reused?

The three files clip_l, t5xxl_fp16, and ae are shared with the full FLUX.1 text-to-image setup — the official tutorial states it plainly: if you've run the full text-to-image version, you only need to newly download flux1-fill-dev.safetensors. But note that it, flux1-dev.safetensors (text-to-image), and flux1-dev-kontext_fp8_scaled.safetensors (Kontext) are three different sets of weights and are not interchangeable. For downloads in China, use the ModelScope mirror (linked in the table above).

⚠️ Original version requires agreeing to the license

The official tutorial reminds you: downloading the Black Forest Labs original flux1-fill-dev requires first agreeing to the usage terms on the black-forest-labs/FLUX.1-Fill-dev page. The links built into the template (table above) point to the Comfy-Org repackaged version, which is also what the template's automatic model download uses when a model is missing. The model is licensed under the FLUX.1 [dev] Non-Commercial License (non-commercial); the official tutorial says generated outputs may be used for personal, scientific, and commercial purposes — the license text is authoritative.

Once they're in place, press r on the canvas to refresh, then select the corresponding files in the subgraph's four dropdowns (or open the subgraph and pick them in the loader nodes inside).

You should see: all the red missing-model warnings are gone, and the dropdowns show the correct file names.

  • All four files are in place, and the model dropdowns on the subgraph have the files selected

Step 3: Draw the mask to define the area to inpaint ​

Why: Fill only fills in the part enclosed by the mask—the mask is the work area; the more precisely you enclose, the more precisely it changes.

Steps:

Option A: Use the official example image, which comes with a mask (recommended to get it running first) ​

The official inpainting example image flux_fill_inpaint_example_input_image.png already comes with an alpha transparency mask; upload it into Load Image and it works—no drawing needed. If you want to practice drawing your own, the official docs also provide the original image without the mask.

Option B: Your own image, draw the mask with MaskEditor ​

  1. Right-click the Load Image node and choose Open in MaskEditor
  2. In the right panel, adjust the brush size and paint over the area you want to change; if you paint wrong, erase it with the eraser
  3. Click Save to save—what you painted automatically becomes the MASK output of Load Image

💡 Turn a generated image directly into an input image

Right-click the Save Image node and choose Copy(Clipspace), then right-click Load Image and choose Paste(Clipspace)—the previous round's output doesn't need to be saved to disk and re-uploaded; it becomes this round's input directly. Especially handy for multi-round image editing (it will be used in step 6).

You should see: the MASK output of Load Image is wired into the subgraph; the white (painted) area in the mask = the area about to be repainted.

  • Load Image has both the image and the mask, and the MASK output is wired up correctly

Step 4: Run your first ComfyUI inpainting image ​

Why: knowing where the image, mask, and prompt converge gives you direction for tuning and debugging later; once this step runs through, you've mastered the backbone of ComfyUI inpainting.

Steps: double-click the subgraph node to enter it, and check each node against this table:

NodeWhat it doesKey parameters in the template
UNETLoader (Load Diffusion Model)Loads the Fill diffusion modelflux1-fill-dev.safetensors
DualCLIPLoaderLoads two text encoders at oncefirst slot clip_l.safetensors, second slot t5xxl_fp16.safetensors, type flux
VAELoader (Load VAE)Loads the VAEae.safetensors
CLIPTextEncodeEncodes the positive promptDescribes "what should appear inside the mask"
FluxGuidanceFLUX-specific guidance strength30
ConditioningZeroOutZeroes out the negative conditioningcfg 1, no negative prompt needed
DifferentialDiffusionDynamic denoise mask (experimental node)Lets pixels outside the mask undergo extremely light denoising in the final stage of sampling, for more natural blending
InpaintModelConditioningCore: encodes the original image + mask into the conditioningnoise_mask true: samples only inside the mask
KSamplerDenoising sampler20 steps, cfg 1, euler, normal, denoise 1.0
VAEDecode → SaveImageDecodes and savesfile prefix ComfyUI, saved to ComfyUI/output/

Prompt writing: describe the content that should appear inside the mask. For filling in missing parts (the official example's usage), describe the complete picture—the template ships with the example anime girl with massive fennec ears blonde hair blue eyes wearing a pink shirt; to replace an object, focus on describing what the new object looks like.

⚠️ Don't select the two DualCLIPLoader slots in reverse

The official tutorial's step list writes the two slots as clip_name1: t5xxl, clip_name2: clip_l—but the FLUX recipe in the template JSON and in the node source code is first slot clip_l, second slot t5xxl (source code description, original text: flux: clip-l, t5). Just follow the template, not the documentation's step list.

Click Run (called Queue in the old interface), or press Ctrl+Enter.

You should see: the progress bar runs through all 20 steps, and SaveImage outputs the image—the content inside the mask is filled in according to the prompt, while everything outside the mask is identical to the original image.

  • The first inpainting image is out: inside the circle changed, outside untouched

Step 5: Outpainting—extend the image boundary outward ​

Why: outpainting = inpainting with an automatically constructed mask (from the official basic tutorial, verbatim: this is actually just an inpainting workflow, only with different nodes to construct the mask). When the canvas isn't big enough or the composition is too full, use it to claim more space outward.

Steps: go back to the template library and select "Flux.1 Outpaint" (template ID flux_fill_outpaint_example; the search term given in the official docs is "Flux.1 Outpaint"), or directly download flux_fill_outpaint_example.json. The four model files are exactly the same as in step 2, no need to download again. ComfyUI outpainting's backbone is just this one template.

This template is a flat structure with one extra key node, Pad Image for Outpainting:

ParameterTemplate defaultDescription
left / top / right / bottom400 / 0 / 400 / 400How many pixels to expand each side (stepped in multiples of 8); the template expands left, right, and bottom by 400 each, leaving the top unchanged
feathering24Feathering: how smoothly the new area transitions into the original image — the larger, the smoother

It outputs two things: the enlarged canvas (new areas filled with neutral gray) + an automatically generated mask (new areas = the inpaint region). The downstream chain is the same as step 4: InpaintModelConditioning → KSampler → VAEDecode.

Upload your own image and adjust the four edge values as needed — to expand a portrait into a landscape, increase left/right and keep top/bottom at 0. The prompt should describe what should appear in the new areas (the template example is beautiful scenery).

💡 This template has noise_mask turned off

The outpainting template sets InpaintModelConditioning's noise_mask to false: the entire new canvas participates in denoising, the Fill model references the original image stitched into the conditions to rebuild the non-expanded areas to match the original, then completes the gray new areas according to the prompt. At this point DifferentialDiffusion on the model chain has no dynamic mask to adjust, but leaving it there doesn't affect execution.

Run with Ctrl+Enter.

You should see: the canvas grows according to the four edge parameters, the new areas blend naturally with the original image, and the original content stays consistent.

  • Outpainting works: the canvas got bigger, with no hard edges at the seams

Step 6: Iteration and Combination — Chaining Inpaint and Outpaint (Optional) ​

Why: real retouching tasks often need more than one round or more than one method — iteration and combination are Fill at its full potential.

Steps:

  1. Iterative inpainting: not happy with the first round's result? Right-click Save Image → Copy(Clipspace), right-click Load Image → Paste(Clipspace), turn the output into the input, then paint a new mask and keep refining (the official basic tutorial also suggests: repeatedly inpaint the generated result until satisfied)
  2. Outpaint first, then inpaint: flaws in the expanded area? Switch back to the inpainting template and circle the flaws into the mask to fix them separately — large-scale changes go to outpainting, details go to inpainting
  3. E-commerce workflows: expand a product image into a clean display background, remove clutter from the background, then combine with background removal and replacement and product mockups to form a complete pipeline

You should see: over multiple rounds the image gets closer and closer to the desired result, and each round only touches the areas that need changing.

  • (Optional) Iterated one round with Clipspace, or chained inpainting and outpainting once

Checkpoint ✅ ​

  • Local inpainting works: the official sample image or your own image + mask, completed inside the circle, untouched outside
  • Outpainting works: Pad Image for Outpainting's four edge parameters control the expansion direction
  • You can explain InpaintModelConditioning's role: encoding the original image + mask into the Fill model's conditions
  • You remember the iron rules: cfg 1, 20 steps, euler/normal, guidance 30, no negative prompt needed
  • (Optional) Iterated inpainting with Clipspace, or combined inpainting + outpainting to produce one image

Pitfall Warnings ​

❌ Setting feathering to 0 for outpainting ​

Reason: the feathering parameter means "how smoothly the new area transitions into the original image — the larger, the smoother," and the official template defaults to 24. Setting it to zero means giving up the transition, so the seams easily look harsh. Correct approach: keep the default value or increase it appropriately; remember to change the four edge values in multiples of 8 (the node's step size is 8).

❌ Writing a negative prompt in earnest ​

Reason: in the template the negative conditioning is zeroed out directly by ConditioningZeroOut, and KSampler's cfg is 1 — a negative prompt plays no part at all. This is the consensus for the FLUX family (covered in the text-to-image lesson). Correct approach: spend all your descriptive effort on the positive prompt.

❌ Using flux1-dev or kontext weights as Fill ​

Reason: flux1-dev (text-to-image), flux1-dev-kontext (instruction-based editing), and flux1-fill-dev (inpaint/outpaint) are three independently trained weights that are not interchangeable; picking the wrong file at best gives wrong results, at worst mismatches the architecture and errors out immediately. Correct approach: download flux1-fill-dev.safetensors and put it in place per the table in step 2; if the file can't be found, see model loading failure.

❌ Filling both DualCLIPLoader slots following the official documentation's step checklist ​

text
❌ clip_name1: t5xxl_fp16.safetensors   clip_name2: clip_l.safetensors   (the documentation checklist's way of writing it)
✅ clip_name1: clip_l.safetensors       clip_name2: t5xxl_fp16.safetensors (the way written in the template JSON and the node source code recipe)

Reason: the official fill tutorial's run checklist has the two slots reversed; the template JSON's actual values and the FLUX recipe in the node source code (flux: clip-l, t5) both put clip_l in the first slot and t5xxl in the second. Correct approach: follow the template, and select flux for type.

Advanced Tips (Optional) ​

🔧 Two legitimate moves when VRAM is tight: Fill officially only provides the full 22.17GB weights (like text-to-image's flux1-dev, a 12B full version, with no fp8 single-file version). When VRAM falls short: first, in UNETLoader's advanced option weight_dtype select fp8_e4m3fn for quantized loading (a built-in node option); second, swap t5xxl_fp16.safetensors (9.12GB) for t5xxl_fp8_e4m3fn_scaled.safetensors (4.8GB, which is what the Kontext lesson uses). If that still doesn't work, see the system-level solutions in insufficient VRAM.

🔧 Hard marks on inpainting edges: paint the mask a bit larger, circling the entire object you want to change (not just the middle), leaving the model enough room for the transition — the same idea as the grow_mask_by mask expansion in the basic inpainting tutorial; if traces remain, run another small-area inpainting pass to fix the edges.

🔧 How to choose a retouching route: for masked local inpainting and outpainting, use this lesson's Fill; for whole-image instruction-based editing, use Kontext; to retouch with Chinese instructions, see Qwen-Image-Edit and Qwen-Image-2.1; for the complete product-scene pipeline, see E-commerce Image in Practice.

Lesson Summary ​

✅ ComfyUI Local inpainting is working: official template → four files in place → paint the mask in MaskEditor → generate in 20 steps, completed inside the circle, untouched outside.

✅ Outpainting pipeline works: Pad Image for Outpainting expands the canvas by the four-side parameters and automatically generates a mask — essentially "inpainting with an auto-built mask".

✅ Learned to read the inpaint-specific node: InpaintModelConditioning encodes the original image + mask into Fill's conditions; noise_mask on = sample only inside the mask (inpainting), off = the entire canvas participates in denoising (outpainting).

✅ Got how iteration and composition chain together: Clipspace turns output into input; outpaint first, then inpaint, with large areas and fine details split between them.

Key configuration recap:

ConfigurationRecommended valueNotes
Diffusion modelflux1-fill-dev.safetensors (22.17 GB)place in models/diffusion_models/; not interchangeable with flux1-dev / kontext
Text encodersclip_l.safetensors + t5xxl_fp16.safetensors (9.12 GB)place in models/text_encoders/; if VRAM is tight, switch to the t5xxl fp8 version (4.8 GB)
VAEae.safetensors (319.8 MB)place in models/vae/; shared with FLUX.1 text-to-image
DualCLIPLoaderfirst slot clip_l, second slot t5xxl, type fluxFLUX family recipe; the official documentation's step list has these reversed — follow the template
KSampler20 steps, cfg 1, euler, normal, denoise 1.0same configuration as the two official templates
FluxGuidance30official template default
InpaintModelConditioninginpainting noise_mask true / outpainting falsekeep outside the mask vs. rebuild the whole canvas
Pad Image for Outpaintingleft 400 / top 0 / right 400 / bottom 400 / feathering 24template defaults: expand left, right, and bottom by 400 pixels each

Next lesson preview ​

Fill takes "change only what you circle" down to the pixel level; the next lesson's FLUX.2 takes "reference" to a new level — referencing multiple images at once for consistency. Next lesson: FLUX.2: Dev Multi-Reference Consistency and the Klein Lightweight Version.

You will learn:

  • FLUX.2 Dev's multi-reference consistency: reference up to 10 images at once
  • Precise hex brand-color control and professional text rendering
  • Klein lightweight version: run FLUX.2 at a 8.4GB VRAM level
  • Product Mockup workflow: apply your design drafts onto real objects
gaodong.aiAboutPrivacyContact

Independent tutorials, not affiliated with any product mentioned. Product names and trademarks belong to their owners. Check official pages for prices and policies.