{
  "schemaVersion": "1.0",
  "canonicalPage": "https://fileformat.co/ext/jsonl",
  "inspectorUrl": "https://fileformat.co/inspect",
  "spec": {
    "slug": "jsonl",
    "extension": ".jsonl",
    "aliases": [
      ".ndjson"
    ],
    "name": "JSON Lines / Newline-Delimited JSON",
    "shortName": "JSONL",
    "category": "ai-ml",
    "tier": 1,
    "summary": "Streaming line-oriented text format where every newline-separated record is a standalone UTF-8 JSON value—standard for LLM fine-tuning (SFT/DPO) datasets and batch APIs.",
    "technicalNotes": "Line-oriented framing allows O(1) memory streaming and parallel chunk splitting, unlike monolithic JSON arrays. Watch for UTF-8 BOMs and >53-bit integer precision loss in JS.",
    "mimeTypes": [
      "application/jsonl",
      "application/x-ndjson"
    ],
    "identifiers": {
      "specUrl": "https://jsonlines.org/"
    },
    "binarySignature": {
      "endianness": "text",
      "magicBytes": [],
      "containerFamily": "text",
      "headerLayout": [
        {
          "offset": "Line 1",
          "byteOffset": 0,
          "byteLength": 16,
          "lengthLabel": "var",
          "dataType": "utf8_json",
          "fieldName": "record_0",
          "description": "First standalone JSON object terminated by LF (0x0A)"
        }
      ]
    },
    "securityProfile": {
      "riskLevel": "low",
      "allowsArbitraryCodeOrMacros": false,
      "xxeRisk": false,
      "polyglotPrependRisk": false,
      "pickleDeserializationRisk": false,
      "uploadValidationNotes": "Enforce max single-line byte length (e.g. 16 MB) before buffering newline splits to prevent memory exhaustion from newline-free gigabyte files."
    },
    "codeSnippets": {
      "python": "import json, sys\nwith open(sys.argv[1], \"r\", encoding=\"utf-8-sig\") as f:\n    first = json.loads(f.readline())\n    print(\"First JSONL keys:\", list(first.keys()))",
      "typescript": "export async function previewJsonl(file: File) {\n  const chunk = new TextDecoder().decode(await file.slice(0, 4096).arrayBuffer());\n  const firstLine = chunk.replace(/^\\uFEFF/, '').split(/\\r?\\n/)[0];\n  return JSON.parse(firstLine);\n}",
      "rust": "use std::{fs::File, io::{BufRead, BufReader}};\nfn main() -> std::io::Result<()> {\n    let mut line = String::new();\n    BufReader::new(File::open(std::env::args().nth(1).expect(\"usage: <prog> <file>\"))?).read_line(&mut line)?;\n    println!(\"Line 1 ({} B)\", line.len());\n    Ok(())\n}",
      "go": "package main\nimport (\"bufio\"; \"fmt\"; \"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    sc := bufio.NewScanner(f)\n    if !sc.Scan() {\n        fmt.Fprintln(os.Stderr, \"scan:\", sc.Err())\n        os.Exit(1)\n    }\n    fmt.Println(sc.Text())\n}"
    },
    "relatedFormats": [
      "csv",
      "parquet",
      "avro"
    ],
    "verifiedAt": "2026-11-14T16:09:03Z"
  },
  "samples": [
    {
      "id": "jsonl-minimal",
      "filename": "minimal-sft.jsonl",
      "variant": "minimal",
      "title": "Minimal UTF-8 SFT Dataset (.jsonl)",
      "description": "3-line UTF-8 JSON Lines fine-tuning dataset with LF delimiters.",
      "localPath": "/fixtures/v1/jsonl/minimal-sft.jsonl",
      "cdnUrl": "https://fileformat.co/fixtures/v1/jsonl/minimal-sft.jsonl",
      "sizeBytes": 308,
      "sha256": "85b7b589f6426c997e2e17ca60dc35cf0285c8408f1141b39ef574a13de69918",
      "expectValid": true
    },
    {
      "id": "jsonl-realistic",
      "filename": "multilingual-rag-chunks.jsonl",
      "variant": "realistic",
      "title": "Multilingual RAG Corpus Chunks (.jsonl)",
      "description": "10-line JSONL stream featuring CJK/Japanese text, ZWJ emoji sequences, nested arrays, and nullable fields.",
      "localPath": "/fixtures/v1/jsonl/multilingual-rag-chunks.jsonl",
      "cdnUrl": "https://fileformat.co/fixtures/v1/jsonl/multilingual-rag-chunks.jsonl",
      "sizeBytes": 2575,
      "sha256": "20fb244b631707aecb497b1c320f5fde5504679044c7e799326c686bcac6d0a5",
      "expectValid": true
    },
    {
      "id": "jsonl-edge-case",
      "filename": "bom-bigint-malformed.jsonl",
      "variant": "edge-case",
      "title": "UTF-8 BOM + 64-Bit BigInt + Malformed Tail",
      "description": "Starts with EF BB BF BOM, contains 9007199254740993 (> JS Number.MAX_SAFE_INTEGER), and ends with a truncated JSON record.",
      "localPath": "/fixtures/v1/jsonl/bom-bigint-malformed.jsonl",
      "cdnUrl": "https://fileformat.co/fixtures/v1/jsonl/bom-bigint-malformed.jsonl",
      "sizeBytes": 210,
      "sha256": "7b279351978bf216b68fca66051d03953d625b0555450c3f8c59051e0b8f0568",
      "expectValid": false,
      "edgeCaseTag": "UTF-8 BOM + BigInt + Malformed Line"
    }
  ]
}