NDJSON to JSON Array Converter

Paste your NDJSON lines to merge them into one JSON array.

Result

[ { "id": 1, "name": "Ada" }, { "id": 2, "name": "Linus" }, { "id": 3, "name": "Grace" } ]
3
Yes

How it is calculated

The input is split into lines (Windows, Unix and old Mac line endings all work) and blank lines are ignored. Each remaining line is parsed on its own as one JSON value, and the parsed values are collected, in order, into one array, printed with four-space indentation and unescaped Unicode. The tool reports the number of lines converted and a valid flag. A line that is not valid JSON is skipped, not repaired, and flips the flag to No, while the good lines are still converted. A line with the literal null is kept as null. Lines may hold objects, arrays, numbers or strings, and one line may not span several lines of text.

Worked example

Paste three lines: {"id":1,"name":"Ada"}, {"id":2,"name":"Linus"} and {"id":3,"name":"Grace"}. Each is a valid JSON object, so the tool puts them in a single array in the same order: an opening bracket, the three objects separated by commas, and a closing bracket. The line count shows 3 and the valid flag shows Yes. If the second line were damaged, say {"id":2,, the array would hold only two objects, the count would be 2 and the flag No.

Try this example →

Common mistakes

  • Pasting a pretty-printed or multi-line object. Each record must sit entirely on one line, otherwise the individual lines are not valid JSON and are dropped.
  • Ignoring the valid flag. A malformed line is silently left out of the array, so check that the line count matches the number of records you expected.
  • Pasting a JSON array that is already complete. It is read as a single line and comes back wrapped in a second array, giving [[...]].
  • Trailing commas between lines. NDJSON lines are not separated by commas; a line ending in a comma is invalid and is skipped.
  • Using single quotes or unquoted keys, which are accepted by some tools but are not valid JSON and fail here.

About this calculator

NDJSON (Newline Delimited JSON, also called JSON Lines or .jsonl) stores one complete, self-contained JSON object per line instead of wrapping everything in a single top-level array. This format is popular for streaming and append-only data because a producer can write one record at a time without ever needing to rewrite the whole file, and a consumer can process it line by line without loading the entire dataset into memory.

Tools like Elasticsearch's bulk API, Fluentd and other log shippers, Spark and BigQuery data loaders, and many machine-learning dataset formats all emit or expect NDJSON. This converter parses each line as an independent JSON value and combines them into a single pretty-printed JSON array, which is the format most general-purpose JSON viewers, `jq` pipelines, and REST APIs expect when NDJSON isn't directly supported.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    A quick integrity check: the converted-lines count should equal the number of non-empty lines in your file. If it is lower and the validity flag says No, some lines were skipped; typical causes are a record wrapped over two lines or a stray trailing comma. Fix those at the source rather than in the output, since the tool repairs nothing. Where does your NDJSON come from: a database export, an API stream, or logs?

Popular calculators

All Calculators