Nodes/ComfyUI-JK-TextTools/BBOXes to Unified Mask
ComfyUI Node

BBOXes to Unified Mask

Many boxes, one mask — the union node the pack actually recommends

By Nakamura2828·Created 8 months ago·Updated 8 months ago· 0
BBOXes to Unified Mask
  • bboxes
  • combined_mask
  • individual_masks
  • bbox_count
width512
height512
invertfalse

BBOXes to Mask is the node the README stamps RECOMMENDED for anything involving more than one bounding box. Where its single-box sibling BBox to Mask does a clean 1:1 conversion, this one takes a whole list of boxes and produces two things at once: one unified mask that ORs every box together, and a list of individual masks, one per box. Detection workflows that want "a mask of everything detected" need this node specifically.

The most common entry point is a detection JSON blob: run it through the pack's Detection Query, take the bbox_list output, and feed it straight in here. Every detection becomes a rectangle in the combined mask, and each box also gets its own mask for per-object processing. That's the whole "I found five dogs, give me one mask of all of them and a way to touch each one separately" workflow in a single node.

How it works

It declares INPUT_IS_LIST, so it receives the full list at once instead of being iterated item-by-item - that's the crucial difference from the single-box node, and the reason you must use this one for lists. It normalizes both wrapped ([[[x,y,w,h]], ...]) and unwrapped ([[x,y,w,h], ...]) formats, clamps every box to the image bounds, and builds:

  • combined_mask - every box region set to 1, OR'd together.
  • individual_masks - one mask per box (list output, grid icon).
  • bbox_count - how many boxes were processed.

invert flips the whole thing if you need "everything except the detections."

Inputs and outputs

  • bboxes (*) - a list of boxes from Detection Query's bbox_list or JSON to BBox.
  • width (INT, default 512) and height (INT, default 512) - mask canvas size.
  • invert (BOOLEAN, optional, default off).

Outputs: combined_mask (MASK), individual_masks (list of MASK), bbox_count (INT).

The workflow that made it

Detection JSON
  → Detection Query (class_filter: "DOG_*", min_score: 0.7)
  → bbox_list → BBoxes to Mask (width/height = image dims)
  → combined_mask → inpaint / composite / conditioning
  → individual_masks → per-dog processing

Same pattern works with JSON to BBox if your boxes come as a SAM3-style XYXY string - convert to XYWH first, then in here.

Installing it

It's part of ComfyUI-JK-TextTools. ComfyUI Manager → search "JK-TextTools" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Nakamura2828/ComfyUI-JK-TextTools.git

Restart ComfyUI. No model downloads; the only real requirement is PyTorch, which every ComfyUI install already has.

Gotchas

Same trap as its sibling: the mask is sized by the width/height you set, so set them to your actual image dimensions or the mask won't line up when you composite. And don't confuse the two bbox nodes - BBox to Mask is per-box (and iterates a list for you), BBoxes to Mask is per-list (and won't, because it needs the whole list to build the union). If your combined_mask seems to only ever contain one box, you've probably grabbed the wrong node.

CategoryJK-TextTools/bbox

Inputs (4)

NameTypeDefaultDescription
bboxes*
widthINT5121–8192
heightINT5121–8192
invertoptBOOLEANfalse

Outputs (3)

NameTypeDescription
combined_maskMASK
individual_masksMASK
bbox_countINT