Invert Mask
One node that flips which half of the image you're fixing
- mask
- MASK
Invert Mask subtracts your mask from 1.0. White becomes black, black becomes white, and suddenly you're inpainting the other half of the image. It's the smallest node in the mask family - one input, one output, zero settings - and it's also the one that trips up the most people, because half the time the fix isn't "inpaint the thing I painted" but "inpaint everything except the thing I painted."
Why you'll reach for it
Think about what "the mask" means in an inpainting workflow. The mask is where the model regenerates. Most people paint the subject they want to change - but a huge number of real tasks want the opposite: fix the background, leave the subject; extend the canvas, leave the original; relight the scene, leave the person. Every time you've painted the wrong side, the fix is one node, not a repaint.
There's a concrete history here. A1111 users got "inpaint everything outside my selection" as a one-click checkbox; in ComfyUI the same move is literally just dropping an InvertMask between your painted mask and the sampler. The r/comfyui threads from back when people migrated over are full of "it's just inverting the mask, it's one node" being hand-waved - which is true, but you have to know to look for it. Now you do.
Outpainting is the biggest practical case. You place the original image on a bigger canvas, mask the empty border, and you want the border regenerated, not the original photo. The naive mask is backwards - invert it. It's also the standard step for switching a mask between "what to remove" and "what to keep" when a downstream node has the opposite convention.
How it works
There is no mechanism to speak of. The execute function is literally 1.0 - mask, applied elementwise across the whole tensor, on GPU. Soft edges stay soft: a pixel at 0.3 becomes 0.7, so gradients, feathering and antialiasing all survive the flip intact. That's a genuinely nice property and worth knowing - inverting a feathered mask keeps it feathered, which is not true of every mask transform.
The inputs and outputs
mask in, MASK out. That's it. No value to tune, no operation to pick. If you need to also grow or soften the result, chain it after GrowMask or FeatherMask.
Getting it
Core ComfyUI, nothing to install. It's in comfy_extras/nodes_mask.py with the rest of the mask family, and it's been there essentially since masks existed.
Where people get burned
- Convention confusion. The one real trap is assuming your mask's polarity matches what the downstream node expects. Invert Mask is the fix, but only if you check which side is actually being regenerated. Run a mask preview first if you're not sure - a quick sanity check beats a whole regeneration you have to throw away.
- Double inverting yourself. Stack two InvertMasks and you've built a very slow wire. It happens; don't feel bad.
- It won't fix a wrong mask shape. If the mask is too small or in the wrong place, inversion just gives you the wrong place on the other side. Invert changes polarity, not geometry - that's
GrowMaskandCropMask's job.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |