JSON versus JSONL
How JSON and JSONL differ, what converting between them changes, which format fits which job, and how to check that the output works where you need it.
JSON and JSONL use the same syntax for values: the same objects, arrays, strings, numbers, booleans and null. The difference is how records are packaged in a file. That packaging decides how the data can be read, appended to, validated and moved between tools.
What each format is
A JSON text is a single value. It is usually an object or an array, though a lone string, number, boolean or null is also valid. Whitespace between tokens has no meaning, so the same data can be indented across many lines or squeezed onto one without changing what it says. When a JSON file holds several records, they are normally wrapped in one enclosing array and separated by commas.
JSONL, short for JSON Lines, is a sequence of JSON values with one value per line, separated by newline characters. There are no enclosing brackets and no commas between records. Each line must be a complete, valid JSON value on its own, so a record cannot be indented across several lines. The same convention is also called newline-delimited JSON, or NDJSON. The two names come from separate descriptions that agree on the core idea, so if edge cases matter, check which one your tool documents. JSONL files commonly use the .jsonl extension.
The same data in both layouts
The examples below were written by hand to show the structural difference. They are not output captured from any particular tool.
[
{
"id": 1,
"name": "Ada",
"tags": ["admin"]
},
{
"id": 2,
"name": "Lin",
"note": "line one\nline two"
}
]
{"id":1,"name":"Ada","tags":["admin"]}
{"id":2,"name":"Lin","note":"line one\nline two"}
The first is a single JSON array that has been pretty-printed. The second holds the same two records as JSONL. The nested tags array stays inside its record. The line break inside the note value remains an escaped \n sequence rather than a real line break, so the record still fits on one line.
What converting between them actually changes
Conversion changes the container and the whitespace. It does not change the values themselves. Converting a JSON array to JSONL writes each element compactly on its own line and drops the outer brackets and the commas between elements. Converting JSONL to JSON parses each line and collects the results into one array. Either way, the characters stored in the file are rewritten. An editor that only displays JSONL in a formatted view is different from a tool that saves a reformatted file.
- Indentation and layout are discarded. You can re-indent the result, but the exact original spacing is not recovered.
- Line breaks inside string values survive as \n escapes. JSON does not allow a raw newline inside a string, so a compliant serializer never splits a record across lines.
- Key order is not guaranteed. The JSON specification treats object members as unordered, and while many tools keep insertion order, a parse-and-rewrite step is not required to.
- Number precision can shift. Some parsers store every number as a double-precision float, as JavaScript does, so very large integers or long decimals can be rounded during a round trip.
- Duplicate keys behave unpredictably. The specification leaves this to implementations, and many parsers silently keep only the last value.
- Only a top-level array maps cleanly to multiple lines. A top-level object becomes a one-line JSONL file containing a single record.
Which format suits your use
| Criterion | JSON | JSONL |
| Structure | One value; multiple records sit inside an array | One value per line, no wrapper |
| Human reading | Can be pretty-printed with indentation | One compact record per line; lines can get long |
| Large files | Many parsers load the whole document before you can use it | Can be read and processed one line at a time |
| Adding records | Requires editing around the closing bracket and adding a comma | Append a new line |
| Damaged or truncated file | One syntax error usually makes the whole document fail to parse | A bad line can be isolated if the reader skips or reports it |
| Validation | Standard JSON validators apply directly | Validate each line; a whole-file JSON validator usually rejects multi-line JSONL |
| Line-oriented tools such as grep, head, split or wc -l | Awkward on pretty-printed files | Each line is one record |
| Typical uses | Configuration files, API request and response bodies, single documents | Logs, data exports, batch jobs, datasets processed record by record |
| Conversion | To JSONL is clean when the top level is an array | To JSON by collecting lines into an array |
Choose JSON when the data is one document that people will read or edit, or when an API or configuration system expects a single value. Choose JSONL when the data is a stream or collection of independent records that will be appended to, split, filtered or processed without loading everything into memory. If the destination documents an expected format, follow that documentation over any general rule. Many tools accept only one of the two.
Will the output work where you need it?
The most common surprise is a validation error. Pasting multi-line JSONL into an ordinary JSON validator or formatter usually produces an error at the start of the second record. That error reflects a format mismatch, not necessarily bad data. The reverse problem is just as common: a formatter that pretty-prints JSONL spreads records across lines and breaks the format. To check JSONL, validate each line on its own, or use a tool that explicitly supports JSON Lines.
- Line endings: some readers accept Windows-style carriage-return-plus-newline endings, while others leave a stray carriage return at the end of each record. If the file moves between operating systems, confirm what the destination expects.
- Blank lines and the final newline: conventions differ. Some readers skip empty lines and others reject them.
- Encoding: UTF-8 is the expected encoding. A byte-order mark at the start of the file can make the first record fail in some parsers.
- Copy and paste: plain-text editors generally keep line breaks, but chat apps, word processors and rich-text fields can wrap lines, merge them, or swap straight quotes for curly ones. Any of these breaks the data. For anything beyond a small sample, transfer the file instead of pasting it.
- Editor word wrap: soft wrapping only changes the display and is harmless. Make sure the editor is not inserting hard line breaks into long records.
For human review, a pretty-printed copy of a single record is easier to read than a long compact line. A practical pattern is to keep the compact JSONL as the stored form and open a formatted view of individual records when someone needs to inspect them.
Sensitive data and online converters
Web-based formatters and converters vary. Some process input entirely in the browser and others send it to a server, and you usually can't tell which from the interface alone. Don't paste credentials, access tokens, personal data or confidential records into a service unless its documentation states how input is handled. Prefer a local tool for anything sensitive, or redact the values first and convert only the structure.
Converting locally
The commands below show common approaches with jq and Python. They are illustrative and were not run for this guide, so check the documentation for your installed versions before relying on them.
# JSON array -> JSONL (one compact element per line)
jq -c '.[]' data.json > data.jsonl
# JSONL -> JSON array (slurp all lines into one array)
jq -s '.' data.jsonl > data.json
import json
# JSONL -> JSON, skipping blank lines
with open("data.jsonl", encoding="utf-8") as f:
records = [json.loads(line) for line in f if line.strip()]
with open("data.json", "w", encoding="utf-8") as f:
json.dump(records, f, indent=2, ensure_ascii=False)
Gaps in this guide
This comparison rests on the published format descriptions and general parser behavior, not on measurements. It includes no benchmarks of speed or memory use, and no specific validator, editor, converter or assistive technology was tested. Treat the compatibility notes as things to verify in your own destination, not as guarantees.