.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 typeHierarchical
Human readabilityMedium
Nesting supportYes
LLM token efficiencyMedium
File extension.jsonl
MIME typeapplication/x-ndjson
Best forOpenAI/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

Related Formats

All 24 formats

JSONL / 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.