Nodes/ComfyUI Unusual Tools/Fill Mask With Color
ComfyUI Node

Fill Mask With Color

Fill Mask With Color

By Diohim·Created about a year ago·Updated about a year ago· 8
Fill Mask With Color
  • image
  • mask
  • IMAGE
fill_color#FFFFFF

Fill Mask With Color does exactly what it says: take an image and a mask, and paint the masked region a solid color. Everything inside the mask becomes your chosen hex color; everything outside stays untouched. Simple node, and quietly one of the more useful little tricks in a modern inpainting workflow.

Why you'd reach for it

Here's the non-obvious one. Modern edit models - Qwen-Image-Edit, Flux Kontext, the Klein family - don't have the old fill-mode dial that A1111 gave you (original / fill / latent-noise / latent-nothing). The KB's inpainting notes spell out the workaround the community rebuilt by hand: if you want the model to invent something new in the masked region instead of leaning on the pixels already there, you overwrite those pixels with flat white or grey first, so there's nothing left to cling to. To keep the rough composition and only change detail, you blur them instead. Fill Mask With Color is the "flat color" half of that trick, done in one node. Paint the hole grey, hand it to your inpaint pass, and the model has to build from your prompt.

Beyond that it's a general compositing helper: knock a removed-object hole out to a clean solid color, lay a flat backdrop behind a masked subject, or just slam a color into a region to sanity-check that your mask is landing where you think it is. When a mask is behaving weirdly, filling it bright magenta and looking at the result is the fastest debug there is.

How it works

A mask in ComfyUI is a grayscale channel - white means "this pixel is selected," black means "leave it." This node reads that mask and, wherever it's white, replaces the image pixel with your fill color; wherever it's black, it passes the original through. If your mask has soft, feathered edges, the fill blends across them rather than stopping at a hard line, which is what you want when the point is to hand a clean gradient-into-color to a downstream sampler.

The inputs that matter

  • image - the picture you're painting into.
  • mask - where the paint goes. White fills, black keeps. This is the input that decides everything, so get its polarity right before blaming the color.
  • fill_color - a hex string, default #FFFFFF (white). This is a plain text field, so give it a proper hex value like #808080 for the mid-grey that the inpaint trick above wants, or #000000 for black.

Output is a single IMAGE with the masked region filled.

Installing it

Search ComfyUI Manager for "ComfyUI Unusual Tools" and install, then restart. If it isn't listed, clone the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Diohim/ComfyUI-Unusual-Tools

No model downloads, no dependency headaches. It appears under mask/compositing.

Where people get tripped up

First, fair warning: this node isn't in the pack's README - the docs cover the resize, crop, and latent nodes but skip this one entirely - so the behavior described here is read off the node's actual inputs, not a written spec. In practice the gotchas are the usual mask-node ones. Mask polarity is the big one: if the wrong area gets painted, your mask is inverted - flip it upstream. The image and mask need to describe the same dimensions, or the fill won't register where you expect. And fill_color wants a hex string - stick to #RRGGBB rather than gambling on whether a color name is understood, since hex is the format the default hands you and the safe bet. If you're using this for the "force a fresh regeneration" inpaint trick, remember it's only the prep step: the flat color does nothing on its own, it's what lets the next node - your inpaint sampler with proper mask conditioning - build something new instead of echoing what was there.

Categorymask/compositing

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
maskMASK
fill_colorSTRING#FFFFFF

Outputs (1)

NameTypeDescription
IMAGEIMAGE