JSONL and NDJSON

Newline-delimited JSON patterns for logs, streams, ETL, and large-file processing workflows.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

JSONL basics

Each line is its own independent JSON value, usually an object.

JSONL example

Two separate JSON objects on two lines.

jsonANYjsonlndjsonstreaming
json
{"id":1,"event":"signup"}
{"id":2,"event":"login"}

Unlike a standard JSON array, JSONL/NDJSON is line-oriented and stream-friendly.

Convert array JSON to JSONL

Emit one compact object per line.

bashANYjsonjsonljq
bash
jq -c '.[]' users.json

This is a common conversion when moving from API exports to pipeline-friendly input.

Convert JSONL back to a JSON array

Slurp separate lines into one array.

bashANYjsonjsonljq
bash
jq -s . data.jsonl

Useful when a downstream system expects a standard array document.

Processing JSONL files

Practical command-line flows for large or streamed data.

Filter JSONL lines by a field

Select only matching objects from a JSONL stream.

bashANYjsonljqfilter
bash
jq -c 'select(.event == "signup")' events.jsonl

Because each line is a valid JSON object, jq can stream through them efficiently.

Extract one field from each JSONL record

Print a property from every line.

bashANYjsonljqextract
bash
jq -r '.email' users.jsonl

Great for quick exports and checks from structured log files.

Count JSONL records

Count one record per line.

bashANYjsonlwccount
bash
wc -l events.jsonl

Because JSONL uses one record per line, line count often equals record count.

Recommended next

No recommendations yet.