Skip to content
uencoder

NDJSON

NDJSON (newline-delimited JSON) puts one independent JSON object per line, suiting streaming processing of large datasets.

Purpose

To provide a JSON format that can be processed as a stream without loading a whole array into memory.

Mechanism

Each line is a complete JSON value separated by newlines, with no outer array wrapper. A parser reads line by line, enabling streaming. It is common for logs, database exports, and API streams.

Use cases

  • Elasticsearch bulk API
  • Database export and import
  • Log stream processing
  • An intermediate format for big data pipelines

Examples

  • Input
    {"a":1}
    {"a":2}
    Output
    Two JSON objects, one per line

    Newline-delimited

Common errors

A string containing a literal newline breaks the line format
Newlines inside JSON strings are already escaped as \n

Related terms

Related tools

References