{
  "schemaVersion": "1.0",
  "canonicalPage": "https://fileformat.co/ext/avro",
  "inspectorUrl": "https://fileformat.co/inspect",
  "spec": {
    "slug": "avro",
    "extension": ".avro",
    "aliases": [],
    "name": "Apache Avro Object Container File",
    "shortName": "Avro",
    "category": "data-lake",
    "tier": 1,
    "summary": "Row-oriented binary data serialization container widely used in Kafka/Confluent event streaming and Iceberg manifest lists, embedding full JSON writer schema in the file header.",
    "technicalNotes": "Begins with `Obj\\x01` (`4F 62 6A 01`), followed by a ZigZag varint-encoded metadata map (`avro.schema`, `avro.codec`) and a 16-byte random sync marker repeated after every block.",
    "mimeTypes": [
      "application/avro",
      "application/octet-stream"
    ],
    "identifiers": {
      "specUrl": "https://avro.apache.org/docs/current/specification/#object-container-files"
    },
    "binarySignature": {
      "endianness": "little",
      "magicBytes": [
        {
          "offset": 0,
          "hex": "4F 62 6A 01",
          "ascii": "Obj.",
          "description": "Avro Object Container v1 magic ('O','b','j', 0x01)"
        }
      ],
      "containerFamily": null,
      "headerLayout": [
        {
          "offset": "0x00 - 0x03",
          "byteOffset": 0,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "uint8[4]",
          "fieldName": "magic",
          "description": "'Obj\\x01' container signature"
        },
        {
          "offset": "0x04+",
          "byteOffset": 4,
          "byteLength": 32,
          "lengthLabel": "var",
          "dataType": "avro_map",
          "fieldName": "file_metadata",
          "description": "ZigZag varint map containing avro.schema & avro.codec"
        },
        {
          "offset": "hdr_end-16",
          "byteOffset": 36,
          "byteLength": 16,
          "lengthLabel": "16 B",
          "dataType": "uint8[16]",
          "fieldName": "sync_marker",
          "description": "16-byte random block boundary sync token"
        }
      ]
    },
    "securityProfile": {
      "riskLevel": "low",
      "allowsArbitraryCodeOrMacros": false,
      "xxeRisk": false,
      "polyglotPrependRisk": false,
      "pickleDeserializationRisk": false,
      "uploadValidationNotes": "Validate `Obj\\x01` prefix and cap maximum `avro.schema` JSON recursion depth and block decompression size."
    },
    "codeSnippets": {
      "python": "import sys\nwith open(sys.argv[1], \"rb\") as f:\n    buf = f.read(4096)\n    assert buf[:4] == b\"Obj\\x01\"\n    has_schema = b\"avro.schema\" in buf\n    print(f\"Avro v1 container, embedded_schema={has_schema}\")",
      "typescript": "export async function isAvroContainer(file: File) {\n  const b = new Uint8Array(await file.slice(0, 4).arrayBuffer());\n  return b[0] === 0x4f && b[1] === 0x62 && b[2] === 0x6a && b[3] === 0x01;\n}",
      "rust": "use std::{fs::File, io::Read};\nfn main() -> std::io::Result<()> {\n    let mut b = [0u8; 4];\n    File::open(std::env::args().nth(1).expect(\"usage: <prog> <file>\"))?.read_exact(&mut b)?;\n    assert_eq!(&b, b\"Obj\\x01\");\n    println!(\"Valid Avro Obj v1\");\n    Ok(())\n}",
      "go": "package main\nimport (\"fmt\"; \"io\"; \"os\")\nfunc main() {\n    f, err := os.Open(os.Args[1])\n    if err != nil {\n        fmt.Fprintln(os.Stderr, \"open:\", err)\n        os.Exit(1)\n    }\n    defer f.Close()\n    b := make([]byte, 4)\n    if _, err := io.ReadFull(f, b); err != nil {\n        fmt.Fprintln(os.Stderr, \"read:\", err)\n        os.Exit(1)\n    }\n    fmt.Printf(\"Avro magic: %x\\n\", b)\n}"
    },
    "relatedFormats": [
      "parquet",
      "orc",
      "jsonl"
    ],
    "verifiedAt": "2026-11-14T16:09:03Z"
  },
  "samples": [
    {
      "id": "avro-minimal",
      "filename": "minimal-null.avro",
      "variant": "minimal",
      "title": "Minimal Uncompressed Avro Object Container",
      "description": "Real Avro OCF from fastavro with embedded record schema, null codec, and 16-byte sync markers.",
      "localPath": "/fixtures/v1/avro/minimal-null.avro",
      "cdnUrl": "https://fileformat.co/fixtures/v1/avro/minimal-null.avro",
      "sizeBytes": 198,
      "sha256": "8f5420609b6bb63e55d37521ce5163e81467a3ec798784bf5857e3c4131acdfd",
      "expectValid": true
    },
    {
      "id": "avro-realistic",
      "filename": "events-deflate.avro",
      "variant": "realistic",
      "title": "Deflate-Compressed Avro Event Batch",
      "description": "fastavro-written OCF with deflate-compressed block of 10 UserEvent records.",
      "localPath": "/fixtures/v1/avro/events-deflate.avro",
      "cdnUrl": "https://fileformat.co/fixtures/v1/avro/events-deflate.avro",
      "sizeBytes": 241,
      "sha256": "bc90476179aca51aae52611b266a87a02d16fd5392fa551554874ce3218f341a",
      "expectValid": true
    },
    {
      "id": "avro-edge-case",
      "filename": "corrupted-sync-marker.avro",
      "variant": "edge-case",
      "title": "Truncated Avro Sync Marker",
      "description": "Avro block cut off mid-sync-marker — fastavro reader must raise on block-boundary failure.",
      "localPath": "/fixtures/v1/avro/corrupted-sync-marker.avro",
      "cdnUrl": "https://fileformat.co/fixtures/v1/avro/corrupted-sync-marker.avro",
      "sizeBytes": 186,
      "sha256": "6534e49af5871a7f976a650fb164f50be0a9231d34ec2a6e46600354ca5da803",
      "expectValid": false,
      "edgeCaseTag": "Broken 16B Sync Marker"
    }
  ]
}