Comfy-Org/ComfyUI · error · ValueError
bboxes string input is not valid JSON: {exc}
Error message
bboxes string input is not valid JSON: {exc} What it means
boxes_from_input accepts a JSON string, dict, or list. When a non-empty string arrives it must parse as JSON via json.loads; a parse failure (ValueError/TypeError from the JSON decoder) is re-raised with this message including the underlying parser error.
Source
Thrown at comfy_extras/nodes_bounding_boxes.py:244
"text": element.get("text", "") if etype == "text" else "",
"desc": element.get("desc", ""),
"palette": element.get("color_palette", []) or [],
},
})
return boxes
def boxes_from_input(data, width: int, height: int) -> list:
if data is None:
return []
if isinstance(data, str):
text = data.strip()
if not text:
return []
try:
data = json.loads(text)
except (ValueError, TypeError) as exc:
raise ValueError(f"bboxes string input is not valid JSON: {exc}") from exc
if isinstance(data, dict):
if _looks_like_element(data):
return elements_to_boxes([data], width, height)
if _looks_like_bbox(data):
return normalize_incoming_boxes(data)
raise ValueError(
"bboxes dict must be a bounding box (x, y, width, height) or an element (with a 'bbox')"
)
if not isinstance(data, list):
raise ValueError(
"bboxes input must be bounding boxes, elements, or a JSON string, "
f"got {type(data).__name__}"
)
if not data:
return []
first = data[0]
if isinstance(first, list):
return normalize_incoming_boxes(data)View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Validate the string parses with json.loads before wiring it in; fix syntax (double quotes, full brackets)
- Generate the JSON programmatically (json.dumps) instead of string concatenation/f-strings
- If the source emits CSV-style boxes, convert to JSON or pass a list/dict directly (the node accepts native lists/dicts, bypassing parsing)
Example fix
// before
bboxes = "x:10,y:20,width:100,height:50"
// after
import json
bboxes = json.dumps([{"x": 10, "y": 20, "width": 100, "height": 50}]) Defensive patterns
Strategy: validation
Validate before calling
import json
def parses_as_boxes_json(s: str) -> bool:
try:
json.loads(s)
return True
except (ValueError, TypeError):
return False Try / catch
try:
boxes = boxes_from_input(text, w, h)
except ValueError as e:
if 'not valid JSON' in str(e):
text = json.dumps(parse_custom_format(text)) # or fix and retry
boxes = boxes_from_input(text, w, h)
else:
raise Prevention
- Build JSON with json.dumps, never f-strings or concatenation
- Parse-then-validate strings from LLMs/pastes before wiring them in
- Pass native lists/dicts where possible to skip string parsing entirely
When it happens
Trigger: Passing 'x:10,y:20,w:5,h:5' (not JSON), a truncated JSON string, trailing commas, single-quoted keys, or smart quotes copied from a chat/UI; an f-string that interpolated Python reprs into JSON.
Common situations: Paste-from-LLM bbox strings; prompt-template interpolation producing malformed JSON; widgets that send comma-separated coordinates instead of JSON.
Related errors
- bboxes element is missing a valid 'bbox' [ymin, xmin, ymax,
- bboxes element 'bbox' must contain four numbers
- bboxes dict must be a bounding box (x, y, width, height) or
- bboxes items must be bounding boxes (x, y, width, height) or
- HASH_CHECK_FAILED
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/64d92ba1a380b63e.
Report an issue: GitHub.