JSON to JSONL Converter
Turn a JSON array into JSON Lines (NDJSON): one compact record per line, converted locally in your browser.
Turn a JSON array into JSON Lines (NDJSON): one compact record per line, converted locally in your browser.
JSON Lines (also called JSONL or NDJSON, newline-delimited JSON) stores one complete JSON value per line, with no enclosing array and no commas between records. Because each line stands alone, a file can be streamed, appended to and split without parsing the whole thing, which is why data tools prefer it for large datasets.
.jsonl or .ndjson extension.[{"id":1,"name":"Ada","tags":["x"]},{"id":2,"name":"Bo","ok":true}]becomes
{"id":1,"name":"Ada","tags":["x"]}
{"id":2,"name":"Bo","ok":true}Records keep their own keys; nothing forces them into a shared shape.
Chat examples are usually written as an array while you edit them and uploaded as JSONL:
[
{"messages": [
{"role": "system", "content": "You are a terse SQL assistant."},
{"role": "user", "content": "Count rows in orders"},
{"role": "assistant", "content": "SELECT COUNT(*) FROM orders;"}
]},
{"messages": [
{"role": "user", "content": "Line one\nLine two"},
{"role": "assistant", "content": "Got both lines."}
]}
]becomes two lines, one training example each:
{"messages":[{"role":"system","content":"You are a terse SQL assistant."},{"role":"user","content":"Count rows in orders"},{"role":"assistant","content":"SELECT COUNT(*) FROM orders;"}]}
{"messages":[{"role":"user","content":"Line one\nLine two"},{"role":"assistant","content":"Got both lines."}]}The line break inside the second user message stays escaped as \n, so a record never spans two lines.
Paging APIs often return the records inside an object:
{"data": [{"id": 1}, {"id": 2}], "next": null}Because the top level is an object, the result is a single line:
{"data":[{"id":1},{"id":2}],"next":null}To get one line per record, extract data first (in the jq playground the filter is .data) and convert that array.
bq load --source_format=NEWLINE_DELIMITED_JSON; Snowflake, Redshift and Databricks read it too.jq -c '.[]' produces it from the command line.Loaders reject a whole file for one bad record, so a quick check saves a failed job. Convert the finished file back with JSONL to JSON: if it parses, every line is valid JSON. Open the resulting array in the JSON viewer and confirm each record has the keys the service expects, for example a messages list for chat fine-tuning or a custom_id for batch requests. Finally, estimate size and cost per example with the JSON token counter.
For practical purposes, yes. Both mean one JSON value per line separated by \n; the files usually use the .jsonl or .ndjson extension and the application/x-ndjson media type.
It is recommended but optional, and most readers accept both. The converter output stops after the last record, so add a final line break when you save the file if your loader or wc -l count expects one. Avoid blank lines in the middle, which some loaders reject.
It is written as a one-line file containing that object. Only a top-level array is split into several lines.
The input was an object that wraps the array, such as {"data": [...]}. Extract the inner array first with the jq playground or JSONPath tester, then convert it.
No. Each element is re-serialised compactly, so whitespace inside records disappears, but keys, key order, values and Unicode text are kept. Line breaks inside strings stay escaped as \n.
Paste a record into the JSON token counter to estimate the token count per example before uploading.