NDJSON converter

What is a Ndjson Converter?

NDJSON (Newline Delimited JSON), also known as JSON Lines or JSONL, stores one complete JSON value per line. Unlike a JSON array, it can be written and read one record at a time, which makes it ideal for logs, streaming APIs and large data exports. This converter turns NDJSON into a regular JSON array and a JSON array back into NDJSON.

How to use it

  1. Paste NDJSON to get a JSON array, or paste a JSON array to get NDJSON.
  2. Copy the output.

Example

NDJSON (three lines, written here with single quotes for readability):

{ 'id': 1, 'event': 'login' }
{ 'id': 2, 'event': 'view' }
{ 'id': 3, 'event': 'logout' }

As a JSON array this becomes [ {...}, {...}, {...} ] with the same three objects separated by commas.

Rules of the format

  • Each line is a valid JSON value, usually an object.
  • Lines are separated by \n; a trailing newline is allowed.
  • No commas between records and no surrounding brackets.
  • Newlines inside string values must be escaped as \n, so each record stays on one line.

Where JSON Lines is used

  • Google BigQuery and other warehouses load newline-delimited JSON.
  • Elasticsearch bulk API bodies are NDJSON.
  • OpenAI and other LLM batch and fine-tuning files use .jsonl.
  • Structured logs from tools like pino, Bunyan and Docker.

Why not just use an array?

To read a JSON array, a parser must usually load the whole file. With NDJSON you can process gigabytes line by line with constant memory, append new records without rewriting the file, and recover from one corrupt line without losing the rest.

Frequently Asked Questions

What is the difference between NDJSON and JSON Lines?

They are essentially the same format: one JSON value per line. The file extensions .ndjson and .jsonl are both common.

Can a record span multiple lines?

No. Each record must be on a single line, so newlines inside strings must be escaped.

Why use NDJSON instead of a JSON array?

It can be streamed and processed line by line, appended to easily, and is more robust when one record is corrupt.

Which tools use JSON Lines?

BigQuery, the Elasticsearch bulk API, OpenAI batch and fine-tuning files, and many structured logging libraries.