JSONL (JSON Lines) puts one JSON object per line — no wrapping array, no commas between records. It's the standard format for LLM training data, log streaming, and big data pipelines.
JSON → JSONL
Python
import json
with open("data.json") as f:
records = json.load(f) # expects a JSON array
with open("data.jsonl", "w") as out:
for record in records:
out.write(json.dumps(record) + "\n")
jq
jq -c '.[]' data.json > data.jsonl
The -c flag outputs compact (single-line) JSON. .[] iterates array items.
JSONL → JSON (reverse)
Python
import json
records = []
with open("data.jsonl") as f:
for line in f:
records.append(json.loads(line.strip()))
with open("data.json", "w") as out:
json.dump(records, out, indent=2)
When to use JSONL
| Use case | Why JSONL wins |
|---|---|
| LLM training data | One record per line = easy streaming |
| Log files | Append without modifying existing JSON |
| Big data (Spark, BigQuery) | Line-by-line processing = no full load |
| API streaming | Send records as they're ready |
No-code conversion
Use the free JSON to JSONL tool — paste or upload your JSON array and download the JSONL file instantly. The JSONL to JSON tool handles the reverse.
Top comments (0)