JSON Lines converter
Convert JSON Lines to a JSON array, or a JSON array to one JSON value per line.
Runs in your browser. Your input is not uploaded.
Loading the tool…
What it does, how to use it, and questions
What it does
JSON Lines, also called NDJSON, puts one JSON value on each line. Log pipelines and bulk exports use it because a reader can take a line without parsing the whole file.
Blank lines are skipped. A broken line is reported by its line number. The other direction writes a JSON array as one compact value per line.
How to use it
- Paste JSON Lines to get a JSON array, or paste an array to get JSON Lines.
- Fix the line named in the error if one is invalid.
- Copy the result.
Example
Input
{"id":1}
{"id":2}Output
[
{
"id": 1
},
{
"id": 2
}
]Things to watch for
- A pretty-printed JSON object that spans several lines is not JSON Lines. Each line has to be one complete value.
- The array direction requires a JSON array. A single object is rejected, with that reason.
- Trailing commas are not allowed. Use the JSON formatter’s repair on a single value, not on a whole JSON Lines file.
Questions
- What is the difference between JSON Lines and a JSON array?
- An array is one value with commas between items. JSON Lines has no commas between lines and no surrounding brackets, so a writer can append a line.
- Are blank lines an error?
- No. They are skipped.
- Can a line be an array or a string?
- Yes. Any JSON value is accepted. Most files use one object per line.
- Is the file uploaded?
- No. It is parsed in this page.