JSONL ⇄ JSON Array

Convert between JSON Lines (NDJSON) and a JSON array.

Open tool

Overview

The JSONL ⇄ JSON array tool converts between the two most common shapes for a collection of JSON records: NDJSON (one JSON value per line) and a top-level array. It is symmetric — paste either shape in, choose a direction, and get the other shape out.

Pipeline engineers, LLM dataset curators, and log-analytics users reach for this when a producer emits one format and a consumer expects the other. Long-tail searches that lead here include "JSON Lines to array converter", "NDJSON to JSON array", and "convert JSON array to one-per-line format".

How it works

JSON Lines is a streaming-friendly convention: every line is parsed independently, so a partially downloaded file is still partially usable. The JSON array form is the canonical RFC 8259 container — one big value enclosed in […], easier for tools that expect a single document.

The conversion in either direction is structure-preserving: parsing JSONL builds an in-memory list of values that is then serialised as a JSON array; splitting an array iterates its elements and emits one compact JSON line per element. The output JSONL uses \n line endings, no trailing newline ambiguity, and each line is a self-contained JSON document.

Examples

  • Convert a database query result that returned a single JSON array into per-record lines for a streaming consumer.
  • Roll up a folder of single-line NDJSON log files into one tidy JSON array for offline analysis.
  • Sanity-check that every record in an NDJSON file is valid JSON before piping it downstream.
  • Re-emit a pretty-printed JSON array as compact NDJSON suitable for git-friendly diffs.

FAQ

What is the difference between JSONL and NDJSON?
In practice, none. Both describe the same convention — newline-delimited JSON values. JSONL is the more common name on the web; NDJSON is the historical name. Files with either extension work identically.

Are nested arrays a problem?
No. A line in JSONL can itself be a JSON array — only the line separator matters. Nested arrays inside the records are preserved exactly.

How are CRLF line endings treated?
They are normalised to LF in the JSONL output. The parser accepts either on input so files coming off Windows tooling parse fine.

Will the tool stream very large inputs?
The conversion is in-memory, so the practical limit is browser RAM. For multi-gigabyte conversions, prefer a dedicated streaming utility.

Why does my pretty-printed JSON not round-trip?
JSONL requires each record to fit on one line. Going JSON-array → JSONL therefore compacts each element. Going back gives you a pretty-printed array, but the inner records are emitted compact — extra whitespace inside individual records is not preserved.

Try JSONL ⇄ JSON Array

An unhandled error has occurred. Reload ×