ImageAndMaskPreview
See your mask on top of your image
- image
- mask
- composite
Masks are the thing you can never quite see in ComfyUI. A mask is just a grayscale tensor, and the default Preview Image node shows it as a flat white blob with no idea where it actually lands on your picture. That's the problem this node solves: it composites the mask on top of the image so you can finally tell whether your segmentation, your inpaint region, or your ControlNet mask is covering the right stuff.
It comes from kijai's KJNodes, a big grab-bag of utility and optimization nodes that most people already have installed for one reason or another. This is one of the little quality-of-life ones you end up leaving in every masking workflow.
What it actually does
Feed it an image and a mask and it paints the mask over the image as a colored, semi-transparent overlay, then previews the result. Feed it only one of the two and it just previews that. So it doubles as a plain preview when you only have a mask to look at.
The clever bit is pass_through. Normally this is a terminal preview node, it shows you the composite and that's the end of the branch. Flip pass_through on and the preview is disabled and the composite comes back out of the composite output instead. That means you can route the overlaid image into something downstream, most usefully a video-combine node, to build a debug clip that shows your mask animating over the footage frame by frame. Genuinely handy when you're chasing a mask that drifts.
The inputs and outputs that matter
Both image and mask are optional, which is what lets it act as an either/or previewer. The three settings:
mask_color(default"255, 255, 255") - the overlay color as an RGB (or RGBA) string. White is fine for a quick look, but pick something that contrasts with your subject; red or magenta reads far better over skin and landscapes. Because it accepts RGBA, you can bake per-color transparency into the string itself.mask_opacity(default 1.0, range 0–1) - how strongly the overlay covers the image. Drop it to around 0.5 when you want to see the mask and the detail underneath it at the same time.pass_through(default off) - off previews, on returns the composite from thecompositeoutput for downstream use.
The single output is composite (an IMAGE), and it only carries anything meaningful when pass_through is on.
Installing it
You almost certainly have KJNodes already, but if not: open ComfyUI Manager, search KJNodes for ComfyUI, install, restart. Or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt
Then restart ComfyUI. The pack is deliberately light on dependencies, and this particular node needs nothing extra beyond the base install.
Common issues
The overlay is invisible. Your mask_opacity is probably at 0, or your mask_color matches the image, or the mask itself is empty. Bump opacity to 1 and switch the color to red to confirm the mask has any content at all.
Nothing feeds forward. Right, because pass_through defaults to off. If you're wiring the composite output into a video-combine node and getting nothing, turn pass_through on. With it off, this node is a dead-end previewer by design.
The colors look wrong on an RGBA mask. The color string is parsed literally, so a stray value or the wrong number of components will give you a weird tint. Keep it to a clean "R, G, B" or "R, G, B, A" and you're fine.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| mask_opacity | FLOAT | 1.000–1 | — |
| mask_color | STRING | 255, 255, 255 | RGB (255,255,255) or RGBA (255,255,255,128) or Hex (#RRGGBB / #RRGGBBAA) |
| pass_through | BOOLEAN | false | — |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| composite | IMAGE | — |