What Is the Difference Between JSON and JSONL?
JSON: one value (object or array) per file. JSONL (JSON Lines): one JSON object per line, no wrapping array. JSONL is better for streaming and large datasets. In JSON, you must parse the entire file to access any record. In JSONL, you can read and process one line at a time.
Side-by-Side Comparison
JSON (data.json)
[
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25},
{"name": "Charlie", "age": 35}
]
JSONL (data.jsonl)
{"name": "Alice", "age": 30}
{"name": "Bob", "age": 25}
{"name": "Charlie", "age": 35}
Key Differences
| Feature | JSON | JSONL |
|---|---|---|
| Structure | One value per file | One value per line |
| Streaming | Must parse entire file | Process line by line |
| Appending | Must rewrite file | Append a new line |
| Memory | Load entire file | One line at a time |
| Use case | Config, APIs | Logs, datasets, ETL |
Reading JSONL
Python
import json
with open('data.jsonl') as f:
for line in f:
record = json.loads(line)
print(record['name'])
Bash
# Process each line with jq
cat data.jsonl | jq -r '.name'
Try It Yourself
Format your JSON with our JSON Formatter or validate it with our JSON Validator.