Draw Bounding Box Mask
Turn Detected Boxes Into an Inpaint Mask in One Step
- bboxes
- MASK
Bounding boxes are great for "where is the thing," but most ComfyUI tools want a mask. DrawBBoxMask is the shape-shifter: it takes a list of BBOX objects and paints them into a MASK on a canvas you size yourself.
The use case that makes it worth knowing: automated inpainting. Detect a face, a watermark, a stray object - get boxes - and DrawBBoxMask turns those boxes into the exact region VAE Encode (for Inpainting) or any inpaint model wants. It's the difference between "here's where the problem is" and "here's a mask that says fix exactly here."
How it works
The node allocates a zeroed float32 tensor of your chosen width × height and fills every box's region with 1.0. Boxes are clipped to the canvas edges, so out-of-bounds coordinates just get trimmed. One canvas, one mask tensor with a batch dimension, white where the boxes were, black everywhere else.
That's the whole mechanism, and it's refreshingly honest - no blur, no feathering, no antialiased edges. It's a hard-edged mask. If your inpaint wants soft transitions, run a blur node after this one (the pack ships a mask-blur-adjacent toolset elsewhere, or any core Comfy blur works on masks).
Inputs and outputs
- bboxes - the list of boxes (the pack's
BBOXtype) to paint. - width / height - canvas size in pixels, default 512 each, 64–8192 in steps of 8. Match these to the image you'll inpaint, or the mask won't line up.
Output is a MASK.
Where it fits
Classic chain: detection JSON → ParseBBoxQwenVL (or MaskToBBox from an existing mask) → DrawBBoxMask → inpaint. It also composes multiple boxes into a single mask naturally - several detected regions become one multi-region mask in a single node, which is genuinely useful for "remove every detected object" jobs.
Installing it
It's in Duanyll Nodepack like the rest:
cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack
or install via ComfyUI Manager and restart. No models, no downloads.
Gotchas
The canvas size is on you. Feed a 512×512 mask into a 1024×1024 inpaint and it silently covers a quarter of the image - nothing will scream at you. Double-check width/height match the target image. Also remember it's a filled box, not an outline: if you only want the region's edge masked, this isn't the node. And because it's hard-edged, expect pixel-perfect boundaries rather than feathered ones - again, blur after if you need it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| bboxes | BBOX | — | |
| width | INT | 51264–8192 | — |
| height | INT | 51264–8192 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |