Nodes/ComfyUI-UniversalToolkit/Image And Mask Preview (UTK)
ComfyUI Node

Image And Mask Preview (UTK)

Preview that shows your mask on top of the image, not as a gray mystery blob

By whmc76·Created about a year ago·Updated 2 months ago· 72
Image And Mask Preview (UTK)
  • image
  • mask
  • composite
mask_opacity1.00
mask_colorred
pass_throughfalse

Mask debugging in ComfyUI is half the reason people quit. The default mask preview is a white-on-black blob, and after a few dilate/erode passes you genuinely cannot tell whether your mask covers the subject or the sky. Image And Mask Preview (UTK) fixes that by letting you see the mask composited on top of the actual image, in a color you choose, at an opacity you choose. It's one of those "why isn't this built in" nodes.

It's part of ComfyUI-UniversalToolkit, and it does a small job well. You wire an image in, a mask in, and what comes out the composite slot is the image with the mask overlaid - red by default, which reads clearly against most photos.

How it works

If you only connect image, it just passes the image through for preview. Only mask? Same deal, you get the mask as a preview. Connect both and it composites: the mask is scaled by mask_opacity (0 to 1, so you can dial it down to a ghost overlay) and tinted with mask_color, then layered on top of the image using the same composite logic the pack uses elsewhere. Under the hood it delegates to the pack's ImageCompositeMasked helper rather than reinventing blending.

The sneaky good feature is pass_through. Flip it on and the node stops being a pure preview: the composite comes out the output slot instead, so you can wire it into a Video Combine or a save node. The description in the pack says it explicitly - this exists so you can preview and feed the composited result downstream without a second node. Set pass_through true, and your preview is also your render input.

Inputs and outputs

  • mask_opacity (FLOAT, 0–1, default 1) - how strongly the mask shows through.
  • mask_color - red/green/blue/yellow/cyan/magenta/white/black. Red is the sensible default; pick a color that contrasts with your subject.
  • pass_through (BOOLEAN, default false) - off means pure preview; on means the composite is emitted for downstream use.
  • image / mask (optional) - either or both. Both for the overlay.

Single output: composite (IMAGE). It's an output node, so it renders in the UI.

Install and gotchas

Via ComfyUI Manager (search "ComfyUI-UniversalToolkit"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/whmc76/ComfyUI-UniversalToolkit
pip install -r requirements.txt

Restart ComfyUI. No models, no keys, just torch/Pillow you already have.

One gotcha: if your mask is a batch and your image is a single frame, the composite logic recycles the last frame rather than erroring, so check batch sizes when you're reviewing video masks frame by frame. And note the description's wording - "with pass_through on the preview is disabled" - so don't expect both a UI preview and an output when you flip it. It's one or the other, which is the trade for a single output slot.

CategoryUniversalToolkit/Image

Inputs (5)

NameTypeDefaultDescription
mask_opacityFLOAT1.000–1
mask_colorCOMBOred8 options: red, green, blue, yellow, cyan, magenta, +2
pass_throughBOOLEANfalse
imageoptIMAGE
maskoptMASK

Outputs (1)

NameTypeDescription
compositeIMAGE