NDJSON Formatter

Format newline-delimited JSON documents.

Open tool

Overview

The NDJSON formatter cleans up newline-delimited JSON — one JSON object per line, no surrounding array — so each row is parseable on its own. It also converts to and from a standard JSON array, which is what most one-shot consumers expect.

NDJSON (also known as JSON Lines, .jsonl) is the wire format for log streams, large dataset exports from BigQuery and Snowflake, and many Kafka topics. Developers and data engineers reach for an ndjson formatter to validate a file before loading it, or to switch between NDJSON and a single JSON array depending on what their tool consumes.

How it works

NDJSON has a tiny but strict spec: each line is a single, complete JSON value (typically an object); lines are separated by \n; there's no enclosing array; trailing newlines are allowed. The formatter parses each line independently — a bad row doesn't poison its neighbours — and reports per-line errors with line numbers so you can fix issues in place.

Conversion to a JSON array wraps the parsed values in [...] with commas between them. Conversion in the other direction emits one element per line, optionally minified or pretty-printed within each row.

Examples

NDJSON in:
{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}

As JSON array:
[
  {"id":1,"name":"Alice"},
  {"id":2,"name":"Bob"}
]
NDJSON with bad row:
{"id":1,"name":"Alice"}
{id:2}
{"id":3,"name":"Carol"}

Result: 2 valid rows, 1 error at line 2 (unquoted key 'id')

FAQ

Why not just use a JSON array?

NDJSON is streaming-friendly: a consumer can process each line as soon as it arrives without buffering the entire array. That's why log shippers, message queues, and big-data exports prefer it.

Can I have an array as a top-level NDJSON value?

Each line can be any JSON value — object, array, string, number. Most consumers expect objects because they're the only useful row shape, but arrays per line are valid.

Does the formatter preserve the original order?

Yes. Order matters in NDJSON because rows often represent time-ordered events; the formatter never reorders unless you explicitly request sorting.

Try NDJSON Formatter

An unhandled error has occurred. Reload ×