JSON Lines / NDJSON

Convert between JSON arrays and NDJSON (newline-delimited JSON) format.

What is JSON Lines (NDJSON)?

JSON Lines (also called NDJSON — Newline Delimited JSON, or JSONL) is a format where each line of a text file is a valid, independent JSON object. Unlike a regular JSON array that wraps all items in [ ], NDJSON has no wrapper — just one JSON object per line, separated by newline characters.

NDJSON is optimized for streaming and appending. You can process a 10 GB log file line-by-line without loading the whole thing into memory. You can append new records by simply adding a line — unlike a JSON array where adding a record requires rewriting the closing bracket. This makes NDJSON the standard format for log pipelines, BigQuery imports, Apache Kafka, and Elasticsearch bulk indexing.

JSON vs NDJSON

FeatureJSON ArrayNDJSON / JSON Lines
Structure[ {...}, {...} ]One JSON object per line
File extension.json.ndjson or .jsonl
StreamableNo — must parse entire fileYes — process line by line
AppendableNo — breaks JSON syntaxYes — just append a line
Memory useLoads entire fileConstant — one line at a time
Common useREST API responsesLogs, BigQuery, Kafka, Spark

Reading NDJSON in Node.js

javascript
import { createReadStream } from 'fs';
import { createInterface } from 'readline';

const rl = createInterface({ input: createReadStream('data.ndjson') });

for await (const line of rl) {
  if (line.trim()) {
    const record = JSON.parse(line);
    console.log(record.id);
  }
}

Reading NDJSON in Python

python
import json

with open('data.ndjson') as f:
    for line in f:
        if line.strip():
            record = json.loads(line)
            print(record['id'])

Frequently Asked Questions

NDJSON (Newline Delimited JSON) stores one valid JSON object per line. Also called JSON Lines (.jsonl) or ldjson. Each line is independently parseable.

NDJSON is streamable and appendable. You can process a 10 GB log file line-by-line with constant memory, unlike a JSON array that must be fully parsed first.

Yes — BigQuery uses NDJSON as its native JSON import format. Export your array to NDJSON with this tool and import it directly.

The tool reports the exact line number of the first parse error so you can fix the problematic record.

Related Tools