- bbox
- mask
BBOX to Mask is the simplest node in the JK-TextTools pack, and it's deliberately that way. You give it a single bounding box and the image dimensions, and it gives you back a binary mask - white rectangle on black, done. It's the bridge between detection boxes and anything that wants a mask: inpainting, outpainting, compositing, region-based conditioning.
Why would you want a mask instead of a box? Because masks are what ComfyUI's image-processing nodes actually consume. A box tells you where, a mask gives you something you can multiply, blur, invert, and composite with. If your detector hands you boxes, converting them to masks is the step that makes them usable.
How it works
It creates a torch float tensor of height × width, fills the box region with 1.0, and outputs it as a MASK. Coordinates are clamped to the image bounds, so a box that pokes off the edge doesn't blow up - it just gets trimmed. It tolerates both the wrapped [[x, y, w, h]] form and a bare [x, y, w, h], which is a nice touch given how many different things produce slightly different bbox shapes.
Turn on invert and you get the opposite: the box is black, everything around it white. That's your "protect everything except this region" mask.
Inputs and outputs
bbox(BBOX) - one box in[[x, y, width, height]]XYWH form.width(INT, default 512) andheight(INT, default 512) - the mask canvas size.invert(BOOLEAN, optional, default off).
Output is a single mask (MASK). That's it.
The one real trap
This node used to do more. In v1.0.1 the author deliberately stripped it back to a clean 1:1 converter and moved the union/combined-mask behavior to a separate node - BBoxes to Mask. So if you have a list of boxes and you're expecting one unified mask, you've grabbed the wrong node. Use BBoxes to Mask for that, and this one for a single box.
That said, this one does play nice with lists: because it takes a single BBOX input, when you connect it to a list-producing output (like Detection Query's bbox_list), ComfyUI automatically iterates and runs it once per box. You get one mask per box, each handled individually - which is exactly right for per-object processing.
Width and height matter
The mask is created at whatever width/height you set, not "borrowed" from the image. If you feed it a bbox from a 1024×1024 image but leave width/height at 512, the mask comes out half-size and misaligned when you composite. Wire your actual image dimensions in, or take them from an image-size node upstream. It's the most common self-inflicted wound with this one.
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 and you're done. No models to download, no extra pip packages - just ComfyUI and PyTorch.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| bbox | BBOX | — | |
| width | INT | 5121–8192 | — |
| height | INT | 5121–8192 | — |
| invertopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |