What is an NDJSON file?
NDJSON puts one complete record on each line, so a program can start working through a huge file immediately instead of waiting for all of it. It is the usual shape for logs and large exports. You can convert NDJSON files here, both into the format and out of it.
Specification
| Full name | Newline-Delimited JSON |
|---|---|
| Extensions | .ndjson, .jsonl |
| Media type | application/x-ndjson |
| Compression | Uncompressed |
| Transparency | — |
| Animation | — |
| Multiple pages | — |
| Colour depth | One JSON value per line, UTF-8, no wrapping array |
| Size limits | — |
| Introduced | 2013 |
| Developed by | Community convention, also known as JSON Lines |
| Standard | Open |
| Browser support | Not displayed by browsers |
What NDJSON is used for
- Structured application logs shipped to a log aggregator
- Bulk index and export operations in Elasticsearch and BigQuery
- Machine learning training datasets read one example at a time
- Streaming API responses that emit results as they are computed
Strengths and limitations
What NDJSON does well
- Constant memory processing regardless of how large the file grows
- New records can be appended without rewriting the file
- A single corrupt line can be skipped instead of failing the whole file
Where NDJSON falls short
- Not valid JSON as a whole, so generic JSON tooling rejects it
- Records cannot be pretty-printed, since each one must fit on a single line
- Nowhere to put information about the file as a whole
Convert NDJSON to
Every target this format can be written out as, each on its own page.
Convert to NDJSON
Everything that can be turned into a NDJSON file.
Tools that accept NDJSON
Questions about NDJSON
What is a .ndjson file?
NDJSON puts one complete record on each line, so a program can start working through a huge file immediately instead of waiting for all of it. The extension .ndjson or .jsonl identifies it, and its media type is application/x-ndjson.
How do I open an NDJSON file?
Browsers do not display NDJSON natively, so you either need software that understands it or you convert it to something more common first. Converting is usually the faster route when you only need to look at the contents once.
Is NDJSON lossy or lossless?
Uncompressed. Nothing is discarded, so repeated saves never degrade the contents.
What is NDJSON good for?
Constant memory processing regardless of how large the file grows. New records can be appended without rewriting the file. A single corrupt line can be skipped instead of failing the whole file. In practice that makes it a good fit for structured application logs shipped to a log aggregator, and Bulk index and export operations in Elasticsearch and BigQuery.
What are the drawbacks of NDJSON?
Not valid JSON as a whole, so generic JSON tooling rejects it. Records cannot be pretty-printed, since each one must fit on a single line. Nowhere to put information about the file as a whole.