NDJSON (Newline-Delimited JSON)
NDJSON is a format where each line is a valid JSON object, separated by newline characters. This simple convention enables streaming, line-by-line processing, and appending without parsing the entire file. It is widely used for log files, data pipelines, and API streaming.
MIME Type
application/x-ndjson
Type
Text
Compression
Lossless
Advantages
- + Streamable — process one record at a time without loading the entire file
- + Appendable — add new records by appending lines
- + Works with Unix tools (grep, head, tail, wc)
- + Standard for Elasticsearch bulk, BigQuery, and data pipelines
Disadvantages
- − No standard for the overall file (no top-level schema)
- − Cannot represent a single JSON object spanning multiple lines
- − Less compact than binary formats for large datasets
When to Use .NDJSON
Use NDJSON for log files, streaming data, bulk API requests, and any scenario where line-by-line JSON processing is beneficial.
Technical Details
Each line in an NDJSON file is a complete, self-contained JSON value (typically an object), terminated by \n. There is no wrapping array or comma between records, making it trivial to append, stream, and process with Unix tools.
History
NDJSON (also called JSON Lines or JSONL) emerged from the practical need to stream JSON records. The ndjson.org specification formalized the convention in 2014. It is used by Elasticsearch bulk API, BigQuery, and OpenAI's API.