JSON Lines to JSON
Input
{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}Output
[
{
"id": 1,
"name": "Alice"
},
{
"id": 2,
"name": "Bob"
}
]The lines are wrapped into one array and formatted for reading.
This collects every line of a JSON Lines file into a single JSON array, which is what most parsers, APIs and JavaScript code expect. It is the fix for the common error "Unexpected non-whitespace character after JSON". That message almost always means you handed a JSON Lines file to a JSON parser.
Because each line is parsed independently, a malformed record can be pinpointed exactly: you get its line number instead of a single failure for the entire file.
Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.
Input
{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}Output
[
{
"id": 1,
"name": "Alice"
},
{
"id": 2,
"name": "Bob"
}
]The lines are wrapped into one array and formatted for reading.
The details that decide whether a conversion is correct, and where information can be lost without any error being raised.
Split a JSON array into one record per line.
Indent and beautify JSON, with syntax error locations when available.
Check JSON syntax, inspect error locations when available, and scan for duplicate keys.
Turn a CSV table into a JSON array of objects.