BBox To Mask (MEC) (legacy)
Turn a rectangle into a mask (legacy, and what to use instead)
- bbox
- reference_image
- MASK
Take four numbers - x, y, width, height - and produce a filled white rectangle on a black field. That's the whole node. It's the box-to-mask direction of the little BBox family, and the reason you'd want it is that most masking machinery in ComfyUI wants a mask, while boxes come out of detectors, SAM's box prompts, and hand-typed coordinates.
It's deprecated: the pack removed its standalone BBox nodes in April 2026 as duplicates of Impact Pack and core ComfyUI, then re-registered them as legacy classes so existing workflows still load. The display name carries the tag, and ComfyUI hides deprecated nodes from the search palette. If you're on a fresh graph, Impact Pack's region nodes or a crop node's own mask output will do this for you - but this one is quick, has no dependencies, and does no surprises beyond one.
How it works
Two inputs describe the canvas: image_width and image_height. Optional reference_image overrides both - if you wire an image in, the node takes its height and width and ignores the integers. Then it builds a single-channel float mask, fills y1:y2, x1:x2 with 1.0, and clamps the edges so a box hanging off the canvas can't crash it. Negative coordinates, boxes wider than the frame, boxes that start past the right edge - all handled by clamping.
The output is just MASK. One mask, [1, H, W].
The one surprise
The output is always one mask, even if the reference image is a batch. Wire a 60-frame video in and you get a single mask back, not 60. Feed that into anything that expects a batch and you'll either get a broadcast or a size mismatch, depending on the node. For video you want a mask per frame - the mask-propagate or temporal-anchor nodes in this pack are the honest answer; a static rectangle is what mode = static there is for.
Second thing worth knowing: the rectangle has a hard edge. There's no feather and no blur. A hard rectangular matte composited straight onto footage shows its corners, which is why the box-to-mask path in a real pipeline is normally followed by a grow/feather/threshold stage - the Image Mask Editor's non-destructive result stage, or a mask transform node. If what you actually want is a soft region, this is the wrong tool; it's a stencil, not a matte.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
Or "CustomNodePacks" in ComfyUI Manager, then restart. No models, no downloads. The pack does pull opencv-python and scipy, and its README's advice is worth repeating: check what you already have before installing, because clobbering ComfyUI's bundled numpy or torch is a much worse afternoon than a missing node.
pip list | grep -i "opencv\|scipy\|safetensors"
Where it fits, in 2026
The interesting thing about box-to-mask is that the box usually isn't typed by a human any more. The pattern that took over is: a grounding or detection model finds the thing you named, returns a rectangle, you pad it because detectors are tight, and then you convert to a mask for the inpaint. This node is that last step, in the plainest form available. SAM takes a box prompt directly and will do a better job of turning it into a shape that follows the object - worth reaching for when the object isn't rectangular and you care about the seam.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| bbox | BBOX | — | |
| image_width | INT | 5121–16384 | — |
| image_height | INT | 5121–16384 | — |
| reference_imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |