NDJSON to JSON Array Converter

Combine newline-delimited JSON (NDJSON / JSON Lines) into a single JSON array — compact or 2-space indented. 100% in your browser.

What is an NDJSON to JSON converter?

An NDJSON to JSON converter reads newline-delimited JSON — one JSON value per line, no surrounding brackets — and assembles every line into a single JSON array. It is the inverse of streaming serialisation: take a log-friendly, append-only format and produce a self-describing document you can paste, parse, or pipe through standard JSON tooling.

NDJSON (also called JSON Lines or JSONL) is excellent for streaming, but most consumers — from a JSON viewer to fetch().json() to a Jupyter notebook — expect a single document. This converter bridges those two worlds without you needing to write a one-off script.

How to convert NDJSON to JSON — 4 steps

  1. Paste NDJSON. Drop your .ndjson or .jsonl contents into the input — exported logs, BigQuery output, or any line-delimited stream.
  2. Pick an indent. Compact strips all whitespace; 2-space pretty-prints for readability.
  3. Click Convert. Each line is parsed independently. The first invalid line is reported with its line number.
  4. Copy the array. Paste the result into a JSON viewer, an API request body, or a notebook for further analysis.

Sample input and output

// Input NDJSON
{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}
{"id":3,"name":"Carol"}
// Output JSON (2-space)
[
  { "id": 1, "name": "Alice" },
  { "id": 2, "name": "Bob" },
  { "id": 3, "name": "Carol" }
]

Indent Control

Switch between compact (one-line, smallest) and 2-space pretty output without re-parsing the input.

Precise Line Errors

When a line fails to parse, the converter reports the exact line number — no hunting for the broken record.

Browser-Only

NDJSON is parsed in JavaScript on your machine. Logs and exports — often containing user data — never leave the device.

Common use cases

  • check_circleLoading log file exports into a JSON viewer or tree explorer
  • check_circlePreparing NDJSON dumps from BigQuery, Loki, or Elasticsearch for inspection
  • check_circleBuilding API request bodies that expect a JSON array, not NDJSON
  • check_circleConverting NDJSON for use in pandas (read_json) or other notebook tooling
  • check_circleProducing fixtures for tests that import a JSON array
  • check_circleMaking NDJSON human-readable in a code review or pull-request diff
  • check_circleSharing event streams with non-engineers who paste into a JSON viewer
  • check_circleAuditing the line count of an NDJSON export before downstream processing

NDJSON vs JSON arrays

NDJSON is a streaming format: each line is independent, so producers can append and consumers can read constant memory. JSON arrays are a single document: easier for humans, friendlier to ad-hoc tooling, and required by APIs that expect a single payload. This converter goes from streaming to single-document. Use it when you have a finite NDJSON file and want to feed it into a JSON-array-friendly downstream — and use the reverse converter when you need to turn an array back into a stream.

Round-trip and explore

Convert back to NDJSON, view records as a tree, or validate before processing.

Frequently Asked Questions

Why combine NDJSON into a single JSON array?

Many tools, libraries, and humans expect a single, self-describing JSON document. Once you have a finite NDJSON file you want to inspect in a JSON viewer, paste into a UI, send as a request body, or load in a notebook with json.load, the array form is much more convenient. NDJSON is a streaming format — JSON arrays are the in-memory destination.

What about performance?

For files that fit in memory, performance is excellent — the converter parses each line independently and pushes into an array. Conversion is roughly linear in input size. For multi-gigabyte NDJSON files, do not paste them into a browser tool; use a streaming converter like jq -s or a small Node.js script that reads line by line.

What if a line has invalid JSON?

The converter aborts and reports the exact line number that failed. Common causes: a trailing comma left over from a JSON array, an unescaped newline inside a string, or accidentally pasted whitespace. Empty lines are tolerated and skipped automatically.

Does it preserve record order?

Yes. The output array contains the records in the same order they appear in the NDJSON input — line 1 becomes index 0, line 2 becomes index 1, and so on. This matters for time-ordered logs and event streams where ordering carries meaning.

Compact vs pretty output — which should I pick?

Use compact when you are about to send the JSON over the wire or commit it as a fixture — every byte counts. Use pretty (2-space indent) when you want to read or diff the output in a code review or share it with humans. Both produce identical structure; only the whitespace differs.

What if the NDJSON has trailing commas or commented lines?

NDJSON specifies that each line must be valid JSON, which forbids trailing commas and comments. If your input has either, run it through a pre-processor first or hand-clean it — the strict parser will surface the offending line so you can fix it.

Can I paste a mix of objects and arrays?

Yes. Each line is parsed independently as any JSON value, so you can mix objects, arrays, numbers, strings, and booleans line by line. The output array preserves the exact value of each line. Most real NDJSON contains only objects.

Is my NDJSON sent to your servers?

No. Parsing and array assembly run in JavaScript inside your browser. Open DevTools and check the Network tab when you click Convert — no requests are made. Logs and event exports often contain user data; this tool keeps them on your device.

NDJSON to JSON Array Converter Online — Free JSONL to JSON