Nodes/ComfyUI-KYNode/json string to bbox
ComfyUI Node

json string to bbox

Turn a vision-LLM's answer into a real box

By yorkane·Created 2 years ago·Updated 6 months ago· 10
json string to bbox
  • jsonBbox
  • bboxes
  • bbox list
  • bbox1
  • bbox2
  • bbox3
bboxJSONKeybbox_2d

One detail gives away exactly what this node is for: bboxJSONKey defaults to bbox_2d. That's not a generic placeholder - it's the specific key several vision-language model grounding formats use when you ask them to locate an object and return the result as JSON. This node exists to take that kind of output - the literal text response from a vision LLM - and turn it into a real BBOX object ComfyUI's crop and segmentation nodes can use, no manual JSON parsing required.

The pattern it plugs into

This is a concrete implementation of a pattern worth naming directly: ask a vision-capable model to find something ("locate the person's face and return its bounding box as JSON"), get back a JSON blob, and use that box to drive a crop or a segmentation mask - instead of painting a mask by hand or running a dedicated object detector. It removes the manual masking step while keeping the guarantee that only the located region gets touched. If you're chaining this pack's own KY_OpenAIChat node to a vision model and asking it to locate objects, this is the node that turns the text answer into something the rest of your graph can actually crop with.

Inputs and outputs

Both inputs are optional: jsonBbox (a JSON-typed string, default empty) and bboxes (a BBOX-typed input, default an empty list) - feed either the raw JSON text or an already-typed box object, and bboxJSONKey (default bbox_2d) tells it which key inside that JSON actually holds the coordinates.

Four outputs: bbox list (typed BBOX_LIST, the full parsed set) plus bbox1, bbox2, bbox3 (each typed BBOX) - the first three detections broken out individually, handy if you're only ever expecting a small, known number of boxes and want to wire them to separate downstream crops without an iterator node.

Installing it

ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or git clone https://github.com/yorkane/ComfyUI-KYNode into custom_nodes and restart. No model downloads - this is pure JSON parsing.

Common issues

The single most likely failure: your vision model has to actually be prompted to return JSON with a bbox_2d key specifically, or you have to change bboxJSONKey to match whatever key your model or your own prompt actually produced. A model returning boxes under "box" or "bounding_box" instead won't be picked up until you update the key name to match.

Coordinate convention is the second trap, and it isn't specified anywhere in this node's schema: different vision models disagree on whether they return [x1, y1, x2, y2] or [x, y, width, height], and whether coordinates are normalized 0–1 or raw pixels. If your resulting crops land in the wrong place even though the JSON parsed fine, check your model's actual coordinate convention against what this pack's crop nodes expect - a mismatch here is invisible until you look at the actual numbers.

If you expected three boxes and only got one or two populated, that almost certainly means your model only detected that many objects - bbox2/bbox3 presumably come back empty or default in that case rather than erroring, so check bbox list for the real count before assuming something broke.

CategoryKYNode/BBox

Inputs (3)

NameTypeDefaultDescription
jsonBboxoptJSON
bboxesoptBBOX
bboxJSONKeyoptSTRINGbbox_2d

Outputs (4)

NameTypeDescription
bbox listBBOX_LIST
bbox1BBOX
bbox2BBOX
bbox3BBOX