What it does
JSON Lines (also called JSONL or NDJSON) stores one JSON value per line. It is the format of choice for logs, data exports, streaming APIs, BigQuery and Elasticsearch bulk loads, and machine-learning datasets such as OpenAI fine-tuning files, because a program can read or append one record at a time without loading the whole file.
Many tools, however, expect a single JSON array. This converter turns JSON Lines into a formatted JSON array, and turns a JSON array back into JSON Lines with one compact record per line.
How to use
- Choose the Direction: JSON Lines → JSON, or JSON → JSON Lines.
- Paste your data, upload a
.jsonl,.ndjsonor.jsonfile, or click Sample. - For JSON output, pick 2 or 4 spaces of indentation, or Compact for a single line.
- Copy or download the result, or use Use as input to convert it back.
If a line is not valid JSON, the error names the line number and column, so you can jump straight to the broken record — useful when a log file has one truncated entry among thousands.
Example
These three lines of JSON Lines:
{"id": 1, "event": "signup"}
{"id": 2, "event": "login"}
{"id": 3, "event": "logout"}
become this JSON array:
[
{
"id": 1,
"event": "signup"
},
{
"id": 2,
"event": "login"
},
{
"id": 3,
"event": "logout"
}
]
Converting in the other direction, each element of the array is written as one line, with no spaces, and the file ends with a newline.
When to use which
Use JSON Lines when records are produced or consumed one at a time: appending to logs, streaming results, splitting a large dataset across workers, or processing with line-based tools like grep, head and wc -l. Use a JSON array when a program needs the whole collection at once, such as a configuration file, a fixture for tests, or a response body for a REST endpoint.
FAQ
› What is the difference between JSONL, NDJSON and JSON Lines?
They are names for the same format: one complete JSON value per line, separated by newline characters. JSON Lines (.jsonl) and newline-delimited JSON (.ndjson) differ only in name and file extension.
› Are blank lines allowed?
Blank lines and a trailing newline are skipped when reading. Windows line endings (CRLF) and a UTF-8 byte order mark are handled too.
› My file is pretty-printed JSON with one object over several lines. Why does it fail?
In JSON Lines every value must fit on a single line. If your input is a regular JSON array, switch the direction to JSON → JSON Lines; if it is a sequence of pretty-printed objects, put them into an array first.
› Does the conversion change numbers or key order?
No. Values and key order are kept as they are; only whitespace changes. Very large integers beyond JavaScript's safe range (about 9 quadrillion) may lose precision, as in any browser-based JSON tool.