NDJSON to JSON Converter
CV-14Paste NDJSON, also called JSON Lines or JSONL, and get one JSON array. Switch the action to turn a JSON array back into one value per line.
Runs in your browser. Nothing is uploaded.
NDJSON or JSON array
Result
How to use it
- Paste your NDJSON or JSON array into the input box, or open a file (up to 5 MB) or drop it on the box.
- Choose NDJSON to JSON or JSON array to NDJSON.
- For the array output, pick 2 spaces, 4 spaces, Tab or Minified.
- Copy the result or download it as a .json file.
NDJSON to a JSON array
NDJSON has one complete JSON value on each line. The converter parses every non-empty line and puts the values in one array, in the same order. Blank lines are skipped. Each line may be any JSON value, not only an object. If a line is not valid JSON, the message gives its line and column, and Go to error selects that spot in the input. Numbers and strings are kept as written, so a 20 digit ID is not rounded.
A JSON array to NDJSON
The reverse action needs a top-level array. Each item is written on its own line with no extra spaces, and the lines are joined with line feeds. Whitespace inside each value is removed, but numbers and strings are kept exactly as written. An empty array gives empty output. Output has no trailing newline, so add one if the program that reads your file expects it.
Pretty-printed JSON is not NDJSON
NDJSON puts a whole value on one line, so a document that spans several lines will fail on its first line. When that happens the error says the input looks like one multi-line JSON document. If it is an array, use JSON array to NDJSON; otherwise minify it first. The whole input is held in memory, so for files of many megabytes a command-line tool is the better fit.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Line 3, column 8: Expected a string key. | Line 3 of the input is not valid JSON. Here, a trailing comma comes before the closing brace. | Fix that line, or remove it, then convert again. |
Expected a JSON array at the top level. Each item of the array becomes one line. | JSON array to NDJSON got an object, string or number at the top level instead of an array. | Wrap the value in [ ], or paste the array you meant. |
Input is not valid JSON: Unexpected end of input at line 1, column 4 | The JSON array is cut off or has a syntax error, and the position shows where parsing stopped. | Fix the JSON at that position, then convert again. |
Questions people ask
How do I convert NDJSON to JSON?
Paste the NDJSON into the input box and choose NDJSON to JSON. Every non-empty line is parsed and the values are collected into one JSON array. Copy it or download a .json file. Nothing is uploaded.
What is the difference between NDJSON, JSON Lines and JSONL?
They describe the same idea: one complete JSON value per line, separated by line feeds. JSONL is the common file extension, JSON Lines the name of the format, and NDJSON is a close variant. This tool reads and writes that shape.
How do I convert a JSON array to NDJSON?
Choose JSON array to NDJSON and paste an array. Each item is written on its own line with no extra spaces. The top level must be an array. The output has no trailing newline after the last line.
How do I find the bad line in my JSONL file?
The error names the line number and the column where parsing stopped, such as Line 3, column 8. Go to error selects that position in the input box. Blank lines still count toward the line number.
Does it keep big numbers exact?
Yes. Numbers and strings are copied as written, so 12345678901234567890 is not rounded the way JavaScript would round it. Only the whitespace around and inside values changes.
Can a line hold something other than an object?
Yes. NDJSON allows any JSON value on a line, so numbers, strings, arrays, true, false and null are accepted. They appear in the output array as they were, in the same order.
About this tool
NDJSON (also called JSON Lines or .jsonl) has one complete JSON value per line. NDJSON to JSON parses each non-empty line and puts the values in one array; a bad line is reported with its line and column, and you can jump to it. Blank lines are skipped, and each value may be any JSON value, not only an object. JSON array to NDJSON writes each item of a top-level array as one line with no extra whitespace. Numbers and strings are kept exactly as written, so 20-digit IDs are not rounded, but whitespace inside each value is removed in the NDJSON direction. Pretty-printed JSON is not NDJSON: if a value spans several lines, minify it with the JSON Formatter first. The whole input is held in memory, so very large files are better handled by a command-line tool.