How to Convert JSON to JSONL or NDJSON
Convert JSON to JSONL the right way - turn a JSON array into newline-delimited JSON, strip pretty-print formatting, validate records, and download .jsonl.
JSON arrays are common in APIs. JSONL and NDJSON are common in logs, streaming tools, machine learning datasets, and data pipelines. Converting JSON to JSONL means taking an array and writing each item as one compact JSON value per line. This guide shows how to convert JSON to JSONL or NDJSON online, in JavaScript, and from the command line.
The quickest way: convert JSON to JSONL online
Paste a JSON array into the JSON to JSONL converter, choose whether to keep a final newline, and press Convert JSON to JSONL. The tool strips pretty-print formatting, writes one compact record per line, and lets you copy the result or download a .jsonl file.
Use a client-side JSON to NDJSON converter when the data contains logs, internal exports, customer records, or training data. The conversion happens in your browser, so nothing is uploaded.
Use it when: you need newline-delimited JSON for logs, imports, streaming, or command-line processing.
JSON array vs JSONL
A normal JSON array wraps records in brackets and separates them with commas:
[
{ "id": 1, "name": "Ada" },
{ "id": 2, "name": "Grace" }
]
JSONL writes each record on its own line:
{"id":1,"name":"Ada"}
{"id":2,"name":"Grace"}
There are no surrounding brackets and no commas between lines. Each line must be valid JSON by itself.
Strip pretty-print formatting
JSONL is designed for one record per line. That means pretty-printed objects need to become compact first. This:
{
"id": 1,
"name": "Ada"
}
becomes:
{"id":1,"name":"Ada"}
If the input is an array, each item is compacted independently. That is what lets downstream tools read one line at a time.
Keep a final newline
Many command-line tools expect text files to end with a newline. A final newline after the last JSONL record is harmless and often useful:
{"id":1}
{"id":2}
The online converter lets you keep or remove that final newline depending on your pipeline.
Convert JSON to JSONL in JavaScript
The core conversion is small:
const data = JSON.parse(jsonText);
const rows = Array.isArray(data) ? data : [data];
const jsonl = rows.map((row) => JSON.stringify(row)).join("\n") + "\n";
JSON.stringify strips pretty-print whitespace and guarantees each row is valid JSON text. Use an array input when you want multiple lines.
Convert JSON to JSONL with jq
From the command line, jq can emit one compact JSON value per array item:
jq -c '.[]' data.json > data.jsonl
The -c flag means compact output. Without it, each record may be pretty-printed over multiple lines, which is not valid JSONL.
Which method should you use?
For one-off conversion, use the online JSON to JSONL converter: paste a JSON array, convert, and download .jsonl. Use jq -c '.[]' when you are already in the terminal, and use JavaScript when the conversion is part of an app or build pipeline.
Need the reverse? Use JSONL to JSON. New to the format? Read what is JSONL / NDJSON.
Ready to merge your JSON?
Combine files or snippets in your browser — free and private.
Open the merge toolKeep reading