.ndjson

What is a .ndjson file?

Newline-Delimited JSON · Data · Community convention · 2012

NDJSON stores one JSON object per line, with each line a complete record. This makes it perfect for streaming and log data, because a program can process the file line by line without loading it all into memory.

Category
Data
Type
Plain text
Also seen as
.jsonl
Is a .ndjson file safe to open? Safe. NDJSON is plain text data. It does not execute; only the program reading it decides what to do with each record.

What is a .ndjson file used for?

Ordinary JSON must be read in full to be valid, but NDJSON (also seen as JSONL, JSON Lines) breaks that limit: every line stands alone. You can append records to the end of the file, and tools can read them one at a time.

It is widely used for exporting large datasets, log streams and machine-learning training data. Because each line is normal JSON, standard tools parse it easily once split on newlines.

How to open a .ndjson file

The .ndjson format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .ndjson file.

Windows

  • VS Code
  • Python
  • jq

macOS

  • VS Code
  • Python
  • jq

Linux

  • VS Code
  • Python
  • jq

How to convert a .ndjson file

You can convert a .ndjson file to JSON, CSV, Parquet using a conversion tool or the export menu of an app that opens it.

.ndjson file signature (magic bytes)

Programs recognise a .ndjson file by the bytes at the start of the file, not by its name. These are the signatures for NDJSON.

Hex signatureOffsetNote
7B0'{' first record (usually)

See the full magic-numbers reference for every format.

Frequently asked questions

What is a .ndjson file?

NDJSON stores one JSON object per line, with each line a complete record. This makes it perfect for streaming and log data, because a program can process the file line by line without loading it all into memory.

What is the difference between JSON and NDJSON?

A JSON file is one value that must be parsed whole. NDJSON is many JSON values, one per line, so it can be streamed and appended to.

How do I open an NDJSON file?

Any text editor shows it. To process it, read line by line and parse each line as JSON, or use jq with the --stream or -c options.

Is JSONL the same as NDJSON?

Effectively yes. JSON Lines (.jsonl) and NDJSON both mean one JSON object per line separated by newlines.

Related formats

Sources

Details on this page were checked against authoritative references: