.jsonlapplication/x-ndjsonLLM & Streaming Formats

JSON Lines (NDJSON) (JSONL)

LLM fine-tuning datasets (OpenAI/Anthropic ChatML), evaluation benchmarks, batch APIs, and append-only structured logs.

Quick Answer

JSON Lines (JSONL / NDJSON) stores one self-contained JSON value per UTF-8 newline, enabling line-by-line streaming, sharding, and OpenAI/HuggingFace training pipelines without parsing the entire file.

JSONL · Format specs
PropertyJSONL
File extension.jsonl
MIME typeapplication/x-ndjson
Structure typeLine Stream
EncodingUTF-8 Text
Nesting supportYes
LLM token efficiencyMedium
Schema / typedNo
Best forLLM fine-tuning datasets (OpenAI/Anthropic ChatML), evaluation benchmarks, batch APIs, and append-only structured logs.

Strengths

  • Streamable line by line — process or shard huge datasets without loading one giant JSON array
  • Required format for OpenAI Fine-Tuning API, Batch API, and most LLM evaluation frameworks
  • Append-only friendly for event logs and partial error recovery on individual lines

Trade-offs

  • One malformed JSON line does not invalidate neighbors, but still halts strict dataset uploads unless audited
  • Each line must stay compact (unescaped raw newlines inside strings break line boundaries)
  • Higher byte footprint than columnar Parquet for numeric analytics

Convert & inspect JSONL locally

Related engineering guides

Related Comparisons

JSONL frequently asked questions

What is the difference between JSONL and NDJSON?

Both mean one valid JSON object per newline (\n). .jsonl is standard in AI fine-tuning datasets while .ndjson is common in HTTP streaming APIs.

How does OpenAI Fine-Tuning validate JSONL files?

Each line must be a valid JSON object containing a messages array with role and content fields, ending cleanly on an assistant turn.

Can I convert CSV or Alpaca datasets into OpenAI JSONL locally?

Yes. Use DataTo OpenAI Fine-Tune Converter or CSV to JSONL to map instruction/output columns into validated ChatML JSONL in browser RAM.

Authoritative References

Explore other formats

All 14 formats →