Why collect JSON Lines into an array
JSON Lines is great for streaming but awkward to read or reuse: most editors, API clients and libraries expect one JSON document, not hundreds of separate ones. Converting to an array lets you:
- Inspect structured logs from Docker, Kubernetes, Cloud Logging or
pinoin a readable, indented form. - Paste a BigQuery or MongoDB export into a test fixture or a mock server.
- Run a JSONPath or jq query across all records at once in the JSON formatter.
- Feed records to a tool such as JSON to CSV that wants an array.
How records are read
The input is read as a stream of JSON values separated by whitespace. That is more forgiving than splitting on newlines alone:
- One record per line, the normal case, works as expected.
- Blank lines between records are ignored.
- A record pretty-printed over several lines is still read as one record.
- Two values on the same line separated by a space are read as two records.
Each record becomes one element of the output array, in input order, printed with two-space indentation. Records do not have to be objects: strings, numbers and arrays are allowed, as JSON Lines permits any JSON value per line. Numbers keep their exact digits, so 64-bit IDs from databases are not rounded. Duplicate keys inside a record produce a warning, and the last value is kept.
A byte-order mark at the start of the file, which some Windows tools write, is skipped automatically.
Finding the broken line
Log files often contain one bad line: a truncated write, a stack trace printed in plain text, or a record with single quotes. When parsing fails, every invalid line is reported separately with its line number, in the form Record on line 2: …, so you can fix them all in one pass rather than one error at a time.
Common culprits are trailing commas after a record ({...},), which happen when someone hand-edits an array into lines, and Python-style 'single quotes' or True/None values.
Options and limits
There are no conversion options. Nothing is dropped or altered, apart from whitespace. If you paste an ordinary JSON array instead of JSON Lines, it is treated as one record, so the output is an array containing your array; use JSON to JSON Lines when you want to go the other way.
Very large logs are limited by your browser’s memory, since the whole input and output live in the tab. Nothing is sent over the network at any point.
Examples
Application log lines
Three log events become a three-element array that is easy to scan or query.
{"ts":"2026-09-14T08:21:05Z","level":"info","msg":"server started","port":8080}
{"ts":"2026-09-14T08:21:09Z","level":"warn","msg":"slow query","ms":1840}
{"ts":"2026-09-14T08:21:12Z","level":"error","msg":"payment failed","order":"ord_8f2k1"}
[
{
"ts": "2026-09-14T08:21:05Z",
"level": "info",
"msg": "server started",
"port": 8080
},
{
"ts": "2026-09-14T08:21:09Z",
"level": "warn",
"msg": "slow query",
"ms": 1840
},
{
"ts": "2026-09-14T08:21:12Z",
"level": "error",
"msg": "payment failed",
"order": "ord_8f2k1"
}
]
Export with blank lines and a big ID
The blank line is skipped and both 16-digit IDs keep their exact value instead of being rounded.
{"id":9007199254740993,"sku":"KB-104","qty":1}
{"id":9007199254740994,"sku":"MS-220","qty":2}
[
{
"id": 9007199254740993,
"sku": "KB-104",
"qty": 1
},
{
"id": 9007199254740994,
"sku": "MS-220",
"qty": 2
}
]
Common errors and how to fix them
| Error | Cause | Fix |
|---|---|---|
Record on line 2: Unexpected end of inputExplained | A record on that line is incomplete, often a truncated log write or a missing closing brace. | Complete or delete the broken line; the other records convert normally once it is fixed. |
Record on line 2: Unexpected content after the end of the JSON valueExplained | Something follows a complete record on the same line, typically a trailing comma left from an array. | Remove the comma at the end of each line. |
Record on line 1: Object keys must use double quotes, not single quotesExplained | The line was written by Python print() or another tool that does not emit strict JSON. | Regenerate the log with json.dumps or replace single quotes with double quotes. |
Frequently asked questions
Does every record need to be on its own line?
No. Records only need whitespace between them, so pretty-printed records spanning several lines are read correctly too.
What happens to blank lines?
They are ignored. They do not create empty or null elements in the array.
Can I convert a .jsonl file with millions of lines?
It works as long as your browser has enough memory for the input and the pretty-printed output. For very large files, jq -s is a better fit.
Will invalid lines be skipped silently?
No. The conversion stops and lists every invalid line with its number, so no record goes missing without you knowing.