.jsonl · application/x-ndjson
JSONL / NDJSON: JSON Lines / Newline-Delimited JSON
JSONL (Newline-Delimited JSON) stores one valid, self-contained JSON value per line separated by \n, enabling line-by-line streaming without loading full arrays.
Quick Answer: JSONL (Newline-Delimited JSON) stores one valid, self-contained JSON value per line separated by \n, enabling line-by-line streaming without loading full arrays. OpenAI/Anthropic/Gemini fine-tuning datasets, batch inference jobs, log ingestion, and streaming ETL.
| Structure type | Hierarchical |
|---|---|
| Human readability | Medium |
| Nesting support | Yes |
| LLM token efficiency | Medium |
| File extension | .jsonl |
| MIME type | application/x-ndjson |
| Best for | OpenAI/Anthropic/Gemini fine-tuning datasets, batch inference jobs, log ingestion, and streaming ETL. |
Strengths
- Required format for OpenAI, Claude, and Vertex AI fine-tuning & batch APIs
- Appends and streams record-by-record without parsing an outer [ ... ] wrapper
- One malformed record affects only a single line rather than breaking the file
Trade-offs
- Pretty-printed multi-line JSON objects are invalid inside a single JSONL line
- Cannot be parsed directly by a single bare JSON.parse() call
- Still repeats JSON field names on every line
References
Convert & clean JSONL / NDJSON locally
Related engineering guides
- Building Valid JSONL Fine-Tuning Datasets from CSV & JSONFormat valid OpenAI chat, Alpaca, and Gemini fine-tuning .jsonl files from spreadsheets and JSON arrays locally with per-line validation.
- TOON vs JSON: Cutting LLM Prompt Token Cost by 30–60%See how Token-Oriented Object Notation (TOON) eliminates repeated JSON keys in uniform arrays to cut GPT-5, Claude 4, and Gemini 2.5 prompt costs.
Related Formats
All 24 formatsJSONL / NDJSON frequently asked questions
Is JSONL the same as NDJSON?
Practically yes. JSON Lines (.jsonl) and Newline-Delimited JSON (.ndjson) both place one compact UTF-8 JSON object per line separated by \n.
Can I convert a CSV directly into OpenAI chat fine-tuning JSONL?
Yes. CSV to JSONL includes preset templates for raw objects, OpenAI chat messages arrays, and Alpaca instruction/input/output datasets.
Why does fine-tuning upload validation reject trailing empty lines or pretty JSON?
Each line in JSONL must be a complete, single-line JSON value. Enabling per-line validation catches blank or malformed lines before upload.