What is JSONL?
Updated November 4, 2026
JSONL (JSON Lines) is a text format that stores one JSON value on each line. Because every line stands alone, you can read, write and append records one at a time without loading the whole file. It is widely used for logs, data pipelines and LLM datasets.
{"id": 1, "name": "Ada"}
{"id": 2, "name": "Lin"}
{"id": 3, "name": "Grace"}
The rules
The JSON Lines specification sets out these rules:
| Rule | Requirement |
|---|---|
| Encoding | UTF-8, with no byte order mark |
| Each line | One valid JSON value, usually an object |
| Blank lines | Not valid, because a blank line is not a JSON value |
| Line ending | \n; \r\n also works, since surrounding whitespace is ignored |
| Final newline | Strongly recommended, but not required |
| File extension | .jsonl |
| Media type | application/jsonl may be used, but is not yet standardized |
A record cannot be spread over several lines. Newlines inside strings must be written as \n, which is what JSON encoders do by default.
Why use JSONL
- Streaming: a program can process one line at a time, so memory use stays flat however large the file is.
- Appending: adding a record means writing one more line. A JSON array has to be closed and rewritten.
- Damage stays contained: one corrupt line does not stop the other lines from being read.
- Parallel work: a file can be split at any line boundary and processed in pieces.
Where you will see it
- LLM fine-tuning datasets and batch APIs, such as the OpenAI Batch API
- Agent session logs, such as those from Claude Code
- Application and event logs
- Data exports and machine learning datasets
How to read JSONL
In Python:
import json
with open("data.jsonl", encoding="utf-8") as f:
for line in f:
record = json.loads(line)
With jq, which reads a stream of values natively:
jq '.name' data.jsonl
To look through a file without writing code, use the JSONL viewer. To check that a file follows the rules, use the JSONL validator.