Skip to content
jsoncsvonline

JSON vs JSONL (NDJSON): Key Differences & Streaming Guide

Published

Understand JSON vs JSONL / NDJSON: single documents vs line-delimited records, log ingestion, streaming pipelines, memory efficiency, and conversion.

Quick answer

Standard JSON stores an entire dataset as a single structured document (typically an array or object), requiring the full file to be parsed into memory before accessing records. JSONL (JSON Lines, also called NDJSON or newline-delimited JSON) stores exactly one valid, independent JSON object per line. JSONL is the industry standard for application logging, Kafka message queues, and big-data streaming because systems can append events and process records one line at a time without loading gigabytes into RAM.


Comparison table

Feature Standard JSON JSON Lines (JSONL / NDJSON)
Document structure One single document (enclosed in [ ] or { }) One self-contained JSON object per line
Delimiter Commas between array items Newlines (\n) between records
Parsing model All-or-nothing (must parse whole file to read item) Incremental streaming (process line-by-line)
Append performance Slow (must parse, insert, and re-serialize whole file) Instant (append a new line to the end of the file)
Error resilience One syntax error corrupts the entire document A corrupted line can be skipped without losing other records
File extensions .json .jsonl, .ndjson, .jsonlines, .log
Common uses Config files, REST APIs, document databases Kafka, Docker logs, ClickHouse, BigQuery, AI training datasets

Code example comparison

Standard JSON file (events.json)

[
  {"timestamp": "2026-09-11T10:00:00Z", "event": "user_login", "uid": 101},
  {"timestamp": "2026-09-11T10:01:15Z", "event": "checkout", "uid": 101}
]

JSON Lines file (events.jsonl)

{"timestamp": "2026-09-11T10:00:00Z", "event": "user_login", "uid": 101}
{"timestamp": "2026-09-11T10:01:15Z", "event": "checkout", "uid": 101}

Notice that in JSONL there are no outer brackets [ ] and no trailing commas between lines.


Why data pipelines use JSONL

1. Instant append operations

A live server logging millions of user actions cannot rewrite an entire 10 GB .json file for every HTTP request. With JSONL, the logging daemon simply calls write(record + '\n') at the end of the file.

2. Flat memory consumption

JSON.parse() in V8/Node.js requires holding both the raw text string and the parsed object graph in memory simultaneously. A 2 GB standard JSON file will crash most Node or browser runtimes with an out-of-memory error. In contrast, reading a JSONL file line-by-line keeps memory consumption flat at only a few kilobytes regardless of whether the file is 10 MB or 100 GB.

3. Unix utility compatibility

Because every record occupies exactly one line, standard Linux CLI tools work out-of-the-box:

# View the first 5 records
head -n 5 events.jsonl

# Count total records
wc -l events.jsonl

# Split a 100M-line file into smaller 1M-line chunks
split -l 1000000 events.jsonl chunk_

How to convert JSONL to CSV

Converting JSON Lines into tabular spreadsheets requires parsing each line as an independent record and compiling a union header across varying properties:

  • In the browser with zero uploads: use our JSONL to CSV Converter, which streams lines inside a Web Worker.
  • In Python:
    import pandas as pd
    df = pd.read_json("events.jsonl", lines=True)
    df.to_csv("events.csv", index=False)