COCO vs YOLO vs Pascal VOC: annotation formats explained

By the Annoting team · Updated · 5 min read

Short answer

COCO stores a whole dataset's annotations in one JSON file with pixel coordinates (x, y, width, height); YOLO uses one TXT file per image with normalised center-x, center-y, width and height; Pascal VOC uses one XML file per image with pixel corner coordinates (xmin, ymin, xmax, ymax). Request the format your training framework reads — YOLO for Ultralytics, COCO for Detectron2 and MMDetection.

The three formats at a glance

COCOYOLOPascal VOC
File layoutOne JSON per splitOne .txt per image + class listOne .xml per image
Box encodingx, y, w, h (pixels, top-left)cx, cy, w, h (0–1, normalised)xmin, ymin, xmax, ymax (pixels)
SegmentationPolygons or RLE masksPolygon points (YOLO-seg)Not native (separate PNG masks)
KeypointsYesYes (YOLO-pose)No
Read byDetectron2, MMDetection, torchvisionUltralytics YOLOOlder pipelines, TF Object Detection

COCO JSON

COCO keeps three linked lists — images, annotations and categories — in a single file. Each annotation points to an image ID and a category ID and carries a bbox, an optional segmentation and an area. It is the richest of the three formats and the default for segmentation and keypoint work.

Watch for: category IDs that do not start at 0 or 1 consistently, and the iscrowd flag, which switches segmentation from polygons to RLE.

YOLO TXT

Each image has a text file with one line per object: class index, then the box center and size as fractions of image width and height. Segmentation and pose variants append polygon points or keypoints on the same line. A dataset YAML lists class names in index order.

Watch for: class order — the YAML order is the contract, and reordering it silently relabels the dataset. For pose datasets, flip_idx must match the keypoint order.

Pascal VOC XML

Each image has an XML file listing objects with a class name and corner coordinates, plus flags for truncated and difficult objects. It is human-readable and easy to parse, but has no native polygons or keypoints.

Which one should you ask for?

Ask for the format your training code reads, so delivery is a download and not a conversion project. If you are unsure or use several frameworks, COCO is the safest master format because it holds the most information and converts cleanly to the others. Annoting also delivers CVAT XML, Datumaro and custom schemas.

Annoting services mentioned in this guide

FAQ

Related questions

Can COCO be converted to YOLO?

Yes. Boxes convert by normalising and moving the origin to the box center; polygons convert to YOLO-seg points. Keep a fixed class-index mapping so classes do not shift.

Why are YOLO coordinates normalised?

Values between 0 and 1 make labels independent of image resolution, so images can be resized for training without rewriting the labels.

Which format is best for segmentation?

COCO, because it stores polygons and RLE masks with instance IDs and areas. YOLO-seg works well if you train with Ultralytics.

Have a dataset to label?

Tell us what you're building. We'll scope the annotation with you and send a plan and a per-label quote.