Nodes/ComfyUI-MeshMesh/Masks to Colored Masks
ComfyUI Node

Masks to Colored Masks

Stop squinting at gray masks — color-code them and see what you're actually masking

By meshmesh-io·Created 2 years ago·Updated 2 years ago· 0
Masks to Colored Masks
  • mask
  • IMAGE
colorlist
background#00ff00

ComfyUI's default mask preview is a flat gray overlay, and once you've got three or four masks on the same canvas - person, background, a prop, whatever - you genuinely can't tell them apart. Masks to Colored Masks is the 30-second fix: it turns a MASK tensor into a colored RGBA image, one color per mask, all stacked on a single canvas you can actually read. If you've ever stared at a workflow wondering which region is which, this is the node you reach for.

The same dev (meshmesh-io) also ships mask-combining packs like mm-comfyui-megamask, which people pull into video "flow mask" workflows where each frame has its own silhouette mask. Color-coding is how you make sense of those stacks, and it's why this node exists.

How it works

Under the hood it's about as simple as a mask node gets, and there's one behavior worth knowing before it surprises you. Each mask in the batch is reshaped to RGBA, every non-black pixel gets recolored to the hex you gave it, black pixels get alpha 0, and then each colored mask is alpha-composited onto a background canvas. Net result: a whole batch of masks collapses into one color-coded image, each mask in its own color, overlapping masks blending together. It's batch-to-one, not one-to-one.

The inputs that matter

  • mask (MASK) - your grayscale mask tensor, batched or single.
  • colorlist (STRING, default "") - comma-separated hex colors, one per mask: #ff0000,#00ff00,#0000ff. Fewer colors than masks is fine; the leftovers just render white.
  • background (STRING, default "#00ff00") - the canvas color behind the masks. Green is the default for a reason: it reads as chroma-key and makes your colored masks pop.

Output: IMAGE - one RGBA tensor, ready for SaveImage, a preview node, ControlNet preprocessing, or anything else that wants an IMAGE instead of a MASK.

Installing it

The pack has no requirements.txt - it's pure numpy/PIL/torch, all of which ComfyUI already ships, and there are no model files to download. Cleanest install:

  • ComfyUI Manager → search ComfyUI-MeshMesh → install, or
  • cd ComfyUI/custom_nodes && git clone https://github.com/meshmesh-io/ComfyUI-MeshMesh, then restart ComfyUI.

Where people get burned

  • Spaces after commas in colorlist will crash it. The code splits on , and doesn't strip whitespace, so #ff0000, #00ff00 dies on int(" #", 16). No spaces, ever.
  • The background is opaque, not transparent. The output is always composited over that background color, so you can't get a true RGBA matte out of it - set background to #ffffff if you want white behind your masks.
  • Batch collapse, not batch repeat. Feed it ten video-frame masks and you get one image with all ten overlaid, not ten images. That's the whole point for motion-flow previews, but it's a shock if you expected a batch out.

It's a thin utility, so don't overthink it. If you need colored masks to eyeball, to hand to a ControlNet preprocessor, or to turn into region maps for training data, this is the fastest way there.

Categorymask

Inputs (3)

NameTypeDefaultDescription
maskMASK
colorlistSTRING
backgroundSTRING#00ff00

Outputs (1)

NameTypeDescription
IMAGEIMAGE