COCO annotation export incorrect bbox type

  • Project Type: Instance Segmentation
  • Operating System & Browser: Windows 11 & FireFox 150.0.1
  • Project Universe Link or Workspace/Project ID:
  • Do you grant Roboflow Support permission to access your Workspace for troubleshooting? (No):

When exporting datasets in the coco format the bounding boxes have mixed types (numerics and string) which is not following the coco standard. This is causing issues when importing into datumaro library.

The bbox consistently shows numerics followed by strings:

“bbox”:[1080,5,“451”,“1455”]

Datumaro Exception related to this:

Interestingly, I can still import the exported coco dataset with annotations back into Roboflow without any issues.

This deviates from the Roboflow documentation examples too: What is the COCO JSON Annotation Format?

Hi,
I have the same bug exporting my segmentation dataset in COCO format

I can provide additional information:
This was working in January 2026. Back then, bounding boxes were INTs.

Has the library changed? 3rd example with error in RLE seems like the exporting of “\” is an issue.

Examples: Exporting as COCO format, opening the _annotations.coco.json in Visual Code and formatting:

1st Example:

Bounding box as string ( ints as floats )

   {
        "id": 1290,
        "image_id": 105,
        "category_id": 34,
        "bbox": [
            225,
            294,
            "138.0000",
            "213.0000"
        ],
        "area": 29394,
        "segmentation": [
            [
                225,
                413,
                225,
                457,
                236,
                485,
                248,
  1. Example: now the boundingbox does not align to pixels anymore!!
    AND: segmentation is also floating point…
    {
        "id": 1298,
        "image_id": 108,
        "category_id": 23,
        "bbox": [
            488,
            104,
            "98.0820",
            "1285.1631"
        ],
        "area": 126051.367,
        "segmentation": [
            [
                525.027,
                1389.015,
                549.548,
                1384.688,
                559.645,
                1368.821,
                565.414,

3rd Example: bounding box also as string. In addition, the RLE is wrong (double backslashes)… seems like a python export issue?

{
“id”: 1355,
“image_id”: 112,
“category_id”: 14,
“bbox”: [
0,
39,
“1280”,
“681”
],
“area”: 871680,
“segmentation”: {
“counts”: "g2ic0g2000000000O100001O000000000000O1001O000000000000O11O000000000000O11O000000000000O11O00000000000nIM_B7Q5X2]8\\NGe1]8_NaGa1]8cNaG]1]8fNbGZ1\8iNcGW1\8kNcGU1\8mNcGS1\8oNcGQ1\8POdGP1[8ROdGn0[8SOeGm0[8TOdGl0T8\OlGd0Q8@nG0P8BPH>n7DRH<m7ESH;l7GSH9l7HTH8k7IUH7j7JVH6i7KWH4j7LVH4i7MWH4h7KYH5f7LZH4f7LZH4e7L\\H4d7L\\H4d7L\\H4d7K]H4d7L\\H4d7K]H6b7I_H7a7HH87GaH9_7FbH:^7EcH;]7DdH<\\7BfH>…,
“size”: [
720,
1280
]
},
“iscrowd”: 0
},

As this is still not fixed. For anyone needing to fix this issue here is a small python script with the help of trusty chatgpt:

import json

input_path = input("enter input json filename: ")
output_path = input("enter output json filename: ")

def fix_bbox(bbox):
    """
    Ensures bbox = [x, y, w, h] are numeric.
    Converts string values to float.
    """
    fixed = []
    for v in bbox:
        if isinstance(v, str):
            v = v.strip()
            v = float(v)
        fixed.append(v)
    return fixed

# Load COCO JSON
with open(input_path, "r") as f:
    coco = json.load(f)

# Fix annotations
for ann in coco.get("annotations", []):
    if "bbox" in ann and ann["bbox"] is not None:
        ann["bbox"] = fix_bbox(ann["bbox"])

# Save cleaned file
with open(output_path, "w") as f:
    json.dump(coco, f, indent=2)

print(f"Fixed COCO file saved to: {output_path}")

Hello @NikhilReji

Thanks for the report.

We just released a fix for this. Now the new coco exports are serving integers instead of strings in those fields.
For version exports, if the coco format was exported before, it will keep returning the old malformed file.
To get a new one with the right format, you need to create a new version.

@Rodrigo_Barbosa Thank you for the fix. Creating a new version and exporting again fixes the BoundingBox format error.

@NikhilReji : Yes, i guess most of us did this as a quick fix, but errors need to be fixed at the source :wink:

I still experience some RLE errors, which were not present in January.

thx
Walter

Hi,

i found the bug: It is actually an annotation which is outside of the image, causing the error in the RLE…

how the annotation outside the image could happen, i do not know.