Is it free to convert COCO JSON to Segment Anything 2?
Yes! It is free to convert COCO JSON data into the Segment Anything 2 format on the Roboflow platform.
Convert annotation formats
In this guide, we show you how to convert data between the COCO and Segment Anything 2 formats for free. You can use your converted data to train models and other models that support the Segment Anything 2 format.
Yes! It is free to convert COCO JSON data into the Segment Anything 2 format on the Roboflow platform.
COCO is a common JSON format used for machine learning because the dataset it was introduced with has become a common benchmark.
Below, learn the structure of COCO JSON.
{
"info": {
"year": "2020",
"version": "1",
"description": "Exported from roboflow.ai",
"contributor": "Roboflow",
"url": "https://app.roboflow.ai/datasets/hard-hat-sample/1",
"date_created": "2000-01-01T00:00:00+00:00"
},
"licenses": [
{
"id": 1,
"url": "https://creativecommons.org/publicdomain/zero/1.0/",
"name": "Public Domain"
}
],
"categories": [
{
"id": 0,
"name": "Workers",
"supercategory": "none"
},
{
"id": 1,
"name": "head",
"supercategory": "Workers"
},
{
"id": 2,
"name": "helmet",
"supercategory": "Workers"
},
{
"id": 3,
"name": "person",
"supercategory": "Workers"
}
],
"images": [
{
"id": 0,
"license": 1,
"file_name": "0001.jpg",
"height": 275,
"width": 490,
"date_captured": "2020-07-20T19:39:26+00:00"
}
],
"annotations": [
{
"id": 0,
"image_id": 0,
"category_id": 2,
"bbox": [
45,
2,
85,
85
],
"area": 7225,
"segmentation": [],
"iscrowd": 0
},
{
"id": 1,
"image_id": 0,
"category_id": 2,
"bbox": [
324,
29,
72,
81
],
"area": 5832,
"segmentation": [],
"iscrowd": 0
}
]
}SAM-2 uses a custom dataset format for use in fine-tuning models. You can convert and export data to the SAM 2 format in Roboflow.
Below, learn the structure of Segment Anything 2.
{"image":{"image_id":3,"license":1,"file_name":"A2_jpg.rf.1aa89274b154e74a1f960fbb192c6bf2.jpg","height":416,"width":416,"date_captured":"2024-10-07T11:35:58+00:00"},"annotations":[{"id":3,"bbox":[92,153,193.077471,199.115617],"area":38444.7397669646,"segmentation":{"counts":"...","size":[416,416]}}]}Roboflow is a universal conversion tool for computer vision annotation formats. The Public plan is the best way for those exploring personal projects, class assignments, and other experiments to try Roboflow. To convert your dataset, start by creating a free workspace on the Public plan.
Once your account has been created, click Create New Project.

Upload your data to Roboflow by dragging and dropping your COCO JSON images and annotations into the upload space.

Next, click "Generate New Version" to generate a new version of your dataset:

You can then apply any preprocessing or augmentation steps to your dataset:

After generating, you will be prompted to Export your dataset. You can choose to receive your dataset as a .zip file or a curl download link. Choose Segment Anything 2 when asked in what format you want to export your data. You will see a dropdown with various options like this:

Congratulations, you have successfully converted your dataset from COCO JSON format to Segment Anything 2 format!
Yes! It is free to convert COCO JSON data into the Segment Anything 2 format on the Roboflow platform.
If you have between a few and a few thousand images, converting data between these formats will be quick. But, the time it takes to convert between data formats increases with the more images you have.
Our team will help you start solving business problems on the first call.
Over 16,000 organizations build with Roboflow.