StringMash.com

JSONL to JSON converter

JSON Lines to a JSON array and back, with the failing line named.

Conversion
82 characters
Updates as you type
Swap for JSON to JSONL

Using the converter

Paste JSON Lines, one JSON value per line, and they come out as a single JSON array, formatted for reading. Blank lines are skipped. If a line isn't valid JSON, the error says which line, so a broken record in a long log is quick to find.

Swap to go the other way: paste a JSON array and each item comes out on a line of its own, compact, ready to append to a .jsonl file.

What JSON Lines is

A JSON Lines file holds one complete JSON value on each line, usually an object. It's also called NDJSON, newline-delimited JSON. Because every line stands alone, a program can read the file a line at a time without loading the whole thing, and can add a record just by appending a line.

That makes it common for logs, data exports and machine learning datasets, where files grow long and get written a record at a time. A normal JSON array can't do that: it isn't valid until its closing bracket, so the whole file has to be read before any of it can be used.

Questions

What's the difference between JSONL and NDJSON?

In practice, nothing: both mean one JSON value per line, separated by newlines. The converter reads either.

Can a JSON Lines record span several lines?

No. Each record has to fit on one line, so any line breaks inside a string are written as \n.

Why won't my JSON convert to JSONL?

JSON Lines is a list, so the JSON has to be an array, starting with [. A single object becomes one line on its own: wrap it in [ and ].