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}OutputTwo JSON objects, one per lineNewline-delimited
Common errors
- A string containing a literal newline breaks the line format
- Newlines inside JSON strings are already escaped as \n
Related terms
JSON
JSON (JavaScript Object Notation) is a lightweight data interchange format based on JavaScript object literals, using key-value pairs and arrays. GLOSSARY
JSONL
JSONL (JSON Lines) is equivalent to NDJSON: one JSON object per line, an alternative name for the same format. GLOSSARY
CSV
CSV (comma-separated values) is a tabular data format that separates fields with commas; RFC 4180 defines the standard, and it is widely used for data import and export. GLOSSARY