ComfyUI Node

BboxToBbox

Convert one bounding box between (x,y,w,h) and (x1,y1,x2,y2)

By lldacing·Created 3 years ago·Updated 8 months ago· 96
BboxToBbox
  • bbox
  • bbox
is_xywhfalse
to_xywhfalse

Bounding boxes come in two conventions that don't agree with each other: (x, y, w, h) - a top-left corner plus a width and height - and (x1, y1, x2, y2) - two opposite corners. Different ComfyUI node packs pick different conventions, and there's nothing that forces them to standardize, so it's genuinely common to have a detector node handing you one format while the crop or draw node downstream expects the other. BboxToBbox exists purely to translate between the two, on a single box.

It's a small converter node from comfyui-easyapi-nodes, lldacing's pack of API/plumbing utilities, and the README's own framing is direct about the intent: convert a bbox to either format and return it as a generic value so it can plug into whatever other bbox-consuming node you're pairing it with. The kind of node that produces a bbox in the first place - detector nodes from packs like Impact Pack, which ships its own BBOX/SAM/ONNX detector providers - is exactly the sort of upstream source this converter is built to sit next to.

How it works

You tell it, via is_xywh, what format the box you're feeding in is already in, and via to_xywh, what format you want back. It reads the four numbers according to the input flag and re-emits them according to the output flag. If both flags agree (both true or both false), you'd effectively get the same box back unchanged - the useful case is when they differ.

The inputs and outputs that matter

  • bbox (BBOX, required) - the single bounding box to convert.
  • is_xywh (BOOLEAN, optional, default false) - set this to true if the incoming bbox is already in (x, y, w, h) format; leave it false if it's in (x1, y1, x2, y2) corner format.
  • to_xywh (BOOLEAN, optional, default false) - set this to true to get the result back as (x, y, w, h); leave it false for (x1, y1, x2, y2).
  • Output: bbox - the converted box, typed generically (*) so it can wire into whatever downstream node expects that shape.

How to install it

Through ComfyUI Manager, searching comfyui-easyapi-nodes. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt

Restart ComfyUI afterward. No models needed - this is pure arithmetic on four numbers.

Common issues & troubleshooting

Crop or draw comes out in completely the wrong place. This is almost always a mismatched is_xywh flag - if you tell the node your incoming box is (x,y,w,h) when it's actually corner-format (or vice versa), the conversion math reads the numbers wrong and the result is a nonsensical box, not an error. Check the documentation of whatever node produced your original bbox to confirm its actual format before setting is_xywh.

Box looks unchanged after conversion. If is_xywh and to_xywh are set to the same value, the node has nothing to convert - that's expected, not a bug. You want them different when you're actually translating between formats.

Working with a list of boxes instead of one. Use BboxesToBboxes instead - same conversion logic, built for a list of bounding boxes rather than a single one.

CategoryEasyApi/Bbox

Inputs (3)

NameTypeDefaultDescription
bboxBBOX
is_xywhoptBOOLEANfalse
to_xywhoptBOOLEANfalse

Outputs (1)

NameTypeDescription
bbox*