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

What opens 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.

Windows

  • VS Code
  • Python
  • jq

macOS

  • VS Code
  • Python
  • jq

Linux

  • VS Code
  • Python
  • jq

Open a .ndjson file step by step

  1. Confirm the file really is a .ndjson. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
  2. On Windows, open it with VS Code or Python.
  3. On Mac, use VS Code or Python.
  4. On Linux, try VS Code or Python.
  5. Still stuck? Convert the .ndjson to JSON, which opens more widely.

Why can't I open my .ndjson file?

Almost always because no installed app understands NDJSON. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.

The other possibility is that the file is not really a .ndjson at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.

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.

What is the .ndjson file signature (magic bytes)?

A .ndjson file may start with the hex bytes 7B, which read as { in ASCII. Those bytes are a hint rather than a guarantee, so NDJSON cannot be identified by its header alone.

These are the documented signatures for NDJSON.

Documented magic-byte signatures for the .ndjson format
Hex signatureOffsetASCIINote
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. How sources are ranked and what is deliberately left out is set out in the methodology.