Overview
Convert between JSON arrays and JSON Lines
JSON Lines (JSONL) is a simple format where each line is a single, complete JSON value. There is no surrounding array and no commas between records. This makes JSONL perfect for streaming, log files, and large datasets, because a program can read and process one line at a time without loading the whole file into memory.
ToolHub JSON Lines Converter moves data both ways. It turns a JSON array into JSONL by writing each element as compact JSON on its own line, and it rebuilds a pretty-printed JSON array from JSONL by parsing each line. Everything happens in your browser.
Step-by-step
How to convert JSON and JSONL
- 1
Pick a direction
Choose Array to JSONL to flatten an array into one value per line, or JSONL to Array to collect lines back into an array. - 2
Paste your input
Drop your JSON array or your JSON Lines into the input panel. The output updates live as you type. - 3
Copy the result
Click copy to grab the converted output and use it in your pipeline, export, or API call.
Background
What JSON Lines is
A JSONL file is a sequence of JSON values separated by newlines. Each line must be a valid, self-contained JSON value, usually an object. Unlike a JSON array, there are no opening and closing brackets and no commas between records, so appending a new record is as easy as adding a line.
Array to JSONL
This mode parses your input as a JSON array, then writes each element using compact JSON.stringify output, one per line. Nested objects and arrays inside each element are preserved exactly, just without extra whitespace.
JSONL to Array
This mode reads your input line by line, skips blank lines, and parses each remaining line as JSON. The parsed values are collected into a single array and pretty-printed with 2-space indentation. If any line is not valid JSON, the tool tells you the exact line number that failed.
Use cases
When to use JSONL
Streaming large datasets
Process records one line at a time without loading a giant array into memory.
Machine learning data
Many training and fine-tuning pipelines expect one JSON example per line in JSONL format.
Log files
Structured logs are often written as JSONL so each event is an independent, parseable line.
Bulk API imports
Some APIs and databases accept newline-delimited JSON for fast bulk inserts.
Appending records
Add new entries by writing a single line, with no need to rewrite array brackets.
Data pipelines
Pass records between tools where each stage reads and writes one JSON value per line.
Tips and best practices
- Each JSONL line must be a complete JSON value on its own, with no trailing comma.
- Blank lines are ignored when converting JSONL to an array, so stray newlines are safe.
- Array to JSONL outputs compact JSON, which keeps files small and fast to stream.
- JSONL to Array pretty-prints with 2-space indentation for easy reading.
- If a line fails to parse, the error names the exact line number so you can fix it quickly.
Common questions
What is the difference between JSON and JSONL?
A JSON array wraps all records in brackets and separates them with commas. JSONL puts one JSON value per line with no wrapper and no separators. JSONL is easier to stream and append, while a JSON array is a single valid JSON document.
Why is my JSONL output on one line each?
Array to JSONL uses compact output by design, so each record fits on a single line. This is the standard JSONL layout and keeps files small. If you want indentation, switch to JSONL to Array to expand the data.
What happens to nested objects?
Nested objects and arrays are preserved exactly in both directions. Only whitespace and the outer array wrapper change. The actual data is never altered.
How do I find a bad line in my JSONL?
When a line cannot be parsed, the tool reports the failing line number along with the parser message. Jump to that line in your input, fix the JSON, and the output updates instantly.
100% private