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
JSONL example
{"id":1,"event":"signup"}
{"id":2,"event":"login"}

# Two separate JSON objects on two lines.

Convert array JSON to JSONL
jq -c '.[]' users.json

# Emit one compact object per line.

Convert JSONL back to a JSON array
jq -s . data.jsonl

# Slurp separate lines into one array.

## Processing JSONL files
Filter JSONL lines by a field
jq -c 'select(.event == "signup")' events.jsonl

# Select only matching objects from a JSONL stream.

Extract one field from each JSONL record
jq -r '.email' users.jsonl

# Print a property from every line.

Count JSONL records
wc -l events.jsonl

# Count one record per line.

Recommended next

No recommendations yet.