JSON to BBOX
When your segmentation node speaks XYXY and your mask node wants XYWH
- bboxes
- bbox_count
JSON to BBox exists to solve one specific, extremely common annoyance: a segmentation or detection node hands you bounding boxes as a JSON string, and the bbox nodes in your graph want them in BBOX form. Worse, the two sides often disagree about coordinate format. This node is the translator.
The case the author clearly built it for is SAM3 output. Facebook's SAM3 model (released late 2025, needs a HuggingFace access approval and a wrapper node pack to run in ComfyUI) emits boxes in XYXY - two corners, [x1, y1, x2, y2]. ComfyUI's bbox/mask machinery, including this pack's own BBoxes to Mask, expects XYWH - top-left corner plus width and height. Feeding one into the other silently produces garbage masks, and this node is the fix.
How it works
You paste (or wire in) a JSON array of boxes, tell it the format they're in (input_format) and the format you want out (output_format), and it converts every box. The math is simple: XYXY → XYWH is x = x1, y = y1, w = x2 - x1, h = y2 - y1, and the reverse is just adding width and height back. Each box comes out wrapped as [[x, y, w, h]], which is the shape downstream bbox nodes want. Items that aren't a clean list of four numbers get skipped rather than crashing the run.
A typical SAM3 chain looks like this:
TBG SAM3 Segmentation
→ boxes (JSON, XYXY): "[[245.3, 167.8, 512.6, 389.2], ...]"
→ JSON to BBox (input_format: XYXY, output_format: XYWH)
→ BBoxes to Mask (width/height = image dims)
→ combined_mask
Inputs and outputs
json_string(STRING, multiline) - the JSON array of bboxes. Default[].input_format(enum:XYXY/XYWH) - how the incoming boxes are written.output_format(enum:XYXY/XYWH) - what you want out.
Outputs: bboxes (a list, shown with the grid icon) and bbox_count (INT). Note the bboxes output is a list, so ComfyUI can iterate it - per-box downstream processing works without extra nodes.
Where it fits
Its main job is bridging SAM3-style string-JSON box output into the mask world. If your source already produces a proper BBOX list - like this pack's Detection Query bbox_list - you don't need this node; that path is already structured. Reach for it when the boxes arrive as text.
Installing it
It's part of ComfyUI-JK-TextTools. Install via ComfyUI Manager (search "JK-TextTools") or:
cd ComfyUI/custom_nodes
git clone https://github.com/Nakamura2828/ComfyUI-JK-TextTools.git
Restart ComfyUI. No models, no runtime pip deps beyond ComfyUI + PyTorch.
Gotchas
The silent skip is the thing to watch: a single malformed entry just vanishes from the output, and bbox_count drops accordingly. If your count looks short, eyeball the JSON. And don't assume a node's boxes are XYXY just because it says "SAM" - check the actual JSON; SAM3's own output is XYXY, but some wrappers convert on the way out. When in doubt, print the JSON with the pack's JSON Pretty Printer and read the numbers yourself.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| json_string | STRING | [] | — |
| input_format | COMBO | 2 options: XYXY, XYWH | |
| output_format | COMBO | 2 options: XYXY, XYWH |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| bboxes | * | — |
| bbox_count | INT | — |