JSONL / Array Converter

Convert newline-delimited JSON to an array and back.

Open tool

Overview

The JSONL / JSON array converter switches between two everyday shapes for collections of JSON objects: a newline-delimited JSON Lines stream (one object per line) and a top-level JSON array ([{…}, {…}, …]). Both directions are supported, and the output is pretty-printed or compact on request.

Data engineers shuttling records between log pipelines and analytics tools, ML practitioners preparing training data, and API integrators normalising responses reach for this when the source and destination disagree about format. Long-tail searches that lead here include "convert JSONL to JSON array", "NDJSON to array online", and "split JSON array into JSON Lines".

How it works

JSON Lines (jsonl / ndjson) is a de facto standard documented at jsonlines.org: each line is an independent JSON value (almost always an object), and a newline separates records. It streams cleanly because each line can be parsed in isolation. A JSON array is the standard RFC 8259 container — a single value […] whose elements happen to be objects.

Converting JSONL to an array parses each non-empty line, collects the results, and emits a single array. Going the other way, the converter walks the top-level array and emits each element as a compact JSON line. Whitespace inside individual records (multi-line pretty-printed objects in JSONL) is normalised so that one record always corresponds to exactly one line in the JSONL output.

Examples

  • Turn a 50,000-line analytics log into a single JSON array for ingestion into a tool that lacks a streaming parser.
  • Split a downloaded data.json array into JSONL so it can be processed line-by-line with command-line tools.
  • Compact a verbose pretty-printed array into one-object-per-line for diffing in git.
  • Validate that a JSONL file's records are all parseable before piping to downstream tooling.

FAQ

What happens to comments or trailing commas?
The parser is strict JSON (RFC 8259). Comments and trailing commas are not allowed; clean them up first or use a JSON-with-comments preprocessor.

Does it preserve the original record order?
Yes. Both conversions are order-preserving — record 1 in the input is record 1 in the output.

Is there a record-count limit?
The converter loads the full input into memory, so it is comfortable up to tens of millions of small records but not optimised for truly massive files. For multi-gigabyte streams, use a dedicated streaming tool.

What about empty lines in JSONL?
Empty lines are skipped silently. Whitespace-only lines are likewise ignored, matching how most JSONL consumers behave.

Can the array contain non-object elements?
Yes — the converter handles arrays of strings, numbers, or mixed values just as cleanly as arrays of objects. Each element becomes one JSONL line.

Try JSONL / Array Converter

An unhandled error has occurred. Reload ×