{
  "schemaVersion": "1.0",
  "canonicalPage": "https://fileformat.co/ext/sqlite",
  "inspectorUrl": "https://fileformat.co/inspect",
  "spec": {
    "slug": "sqlite",
    "extension": ".sqlite",
    "aliases": [
      ".db",
      ".sqlite3"
    ],
    "name": "SQLite 3 Database File",
    "shortName": "SQLite 3",
    "category": "data-lake",
    "tier": 1,
    "summary": "Ubiquitous single-file ACID relational B-tree database with a big-endian 100-byte header at offset 0x00 and full SQL DDL catalog stored in Root Page 1 (`sqlite_schema`).",
    "technicalNotes": "Header fields are big-endian! `page_size` at 0x10 equals 65536 when stored as 0x0001. Root B-tree leaf table cells on Page 1 contain raw `CREATE TABLE` / `CREATE INDEX` statements.",
    "mimeTypes": [
      "application/vnd.sqlite3",
      "application/x-sqlite3"
    ],
    "identifiers": {
      "pronomPuid": "fmt/729",
      "specUrl": "https://www.sqlite.org/fileformat2.html"
    },
    "binarySignature": {
      "endianness": "big",
      "magicBytes": [
        {
          "offset": 0,
          "hex": "53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00",
          "ascii": "SQLite format 3.",
          "description": "16-byte null-terminated SQLite 3 header string"
        }
      ],
      "containerFamily": "sqlite",
      "headerLayout": [
        {
          "offset": "0x00 - 0x0F",
          "byteOffset": 0,
          "byteLength": 16,
          "lengthLabel": "16 B",
          "dataType": "char[16]",
          "fieldName": "header_string",
          "description": "'SQLite format 3\\0'"
        },
        {
          "offset": "0x10 - 0x11",
          "byteOffset": 16,
          "byteLength": 2,
          "lengthLabel": "2 B",
          "dataType": "uint16_be",
          "fieldName": "page_size",
          "description": "Database page size in bytes (1 means 65536)"
        },
        {
          "offset": "0x12 - 0x13",
          "byteOffset": 18,
          "byteLength": 2,
          "lengthLabel": "2 B",
          "dataType": "uint8[2]",
          "fieldName": "journal_versions",
          "description": "1=Rollback journal, 2=WAL mode"
        },
        {
          "offset": "0x1C - 0x1F",
          "byteOffset": 28,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "uint32_be",
          "fieldName": "page_count",
          "description": "Total pages in database file"
        },
        {
          "offset": "0x38 - 0x3B",
          "byteOffset": 56,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "uint32_be",
          "fieldName": "text_encoding",
          "description": "1=UTF-8, 2=UTF-16le, 3=UTF-16be"
        }
      ]
    },
    "securityProfile": {
      "riskLevel": "medium",
      "allowsArbitraryCodeOrMacros": false,
      "xxeRisk": false,
      "polyglotPrependRisk": false,
      "pickleDeserializationRisk": false,
      "uploadValidationNotes": "Disable load_extension() and defensive=ON when opening untrusted SQLite files; corrupted shadow tables (FTS3/RTREE) have historically triggered memory corruption in older libsqlite3 builds."
    },
    "codeSnippets": {
      "python": "import struct, sys\nwith open(sys.argv[1], \"rb\") as f:\n    hdr = f.read(100)\n    assert hdr[:16] == b\"SQLite format 3\\x00\"\n    psize = struct.unpack(\">H\", hdr[16:18])[0] or 65536\n    pages, enc = struct.unpack(\">I\", hdr[28:32])[0], struct.unpack(\">I\", hdr[56:60])[0]\n    print(f\"SQLite3 page_size={psize}B, pages={pages}, encoding={enc}\")",
      "typescript": "export async function readSqliteHeader(file: File) {\n  const dv = new DataView(await file.slice(0, 100).arrayBuffer());\n  const rawPs = dv.getUint16(16, false);\n  return { pageSize: rawPs === 1 ? 65536 : rawPs, pages: dv.getUint32(28, false) };\n}",
      "rust": "use std::{fs::File, io::Read};\nfn main() -> std::io::Result<()> {\n    let mut h = [0u8; 32];\n    File::open(std::env::args().nth(1).expect(\"usage: <prog> <file>\"))?.read_exact(&mut h)?;\n    let ps = u16::from_be_bytes([h[16], h[17]]);\n    println!(\"SQLite page_size={}\", if ps == 1 { 65536 } else { ps as u32 });\n    Ok(())\n}",
      "go": "package main\nimport (\"encoding/binary\"; \"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    h := make([]byte, 32)\n    if _, err := io.ReadFull(f, h); err != nil {\n        fmt.Fprintln(os.Stderr, \"read:\", err)\n        os.Exit(1)\n    }\n    fmt.Printf(\"SQLite pages=%d\\n\", binary.BigEndian.Uint32(h[28:32]))\n}"
    },
    "relatedFormats": [
      "duckdb",
      "parquet",
      "avro"
    ],
    "verifiedAt": "2026-11-14T16:09:03Z"
  },
  "samples": [
    {
      "id": "sqlite-minimal",
      "filename": "minimal-users.sqlite",
      "variant": "minimal",
      "title": "Minimal SQLite 3 Database (4KB Single Page)",
      "description": "Valid 4096-byte single-page SQLite 3 database with a `users` table and two UTF-8 rows.",
      "localPath": "/fixtures/v1/sqlite/minimal-users.sqlite",
      "cdnUrl": "https://fileformat.co/fixtures/v1/sqlite/minimal-users.sqlite",
      "sizeBytes": 12288,
      "sha256": "dee45e02f67ee69f23295ad0de07601253ad41c8da4dfb9cb173e5ebb3b71e50",
      "expectValid": true
    },
    {
      "id": "sqlite-realistic",
      "filename": "app-telemetry-schema.sqlite",
      "variant": "realistic",
      "title": "Multi-Page SQLite Schema (42 Tables + Overflow DDL)",
      "description": "SQLite 3 database whose sqlite_schema B-tree spans interior (0x05) pages across 42 tables plus a ~6KB CHECK-constraint DDL stored on an overflow-page chain.",
      "localPath": "/fixtures/v1/sqlite/app-telemetry-schema.sqlite",
      "cdnUrl": "https://fileformat.co/fixtures/v1/sqlite/app-telemetry-schema.sqlite",
      "sizeBytes": 188416,
      "sha256": "0ea395a85610cdf41278eff1b123008b580dfd0d5732e96eb419eab56e8e4bc1",
      "expectValid": true
    },
    {
      "id": "sqlite-edge-case",
      "filename": "truncated-half-page.sqlite",
      "variant": "edge-case",
      "title": "Truncated SQLite Page 1 (2048B of 4096B)",
      "description": "Valid 100-byte SQLite header whose first B-tree page is truncated mid-page.",
      "localPath": "/fixtures/v1/sqlite/truncated-half-page.sqlite",
      "cdnUrl": "https://fileformat.co/fixtures/v1/sqlite/truncated-half-page.sqlite",
      "sizeBytes": 2048,
      "sha256": "3f7627faa065ed6cd65c4fcccd2cbb8493f9d7330fadd9a68b4ca6fccb0e041c",
      "expectValid": false,
      "edgeCaseTag": "Partial B-Tree Page"
    }
  ]
}