JSON Lines (JSONL) ⇔ JSON Array Converter
Convert between JSON Lines format — one JSON object per line — and a standard JSON array. Handy for checking machine learning datasets and log output.
What JSON Lines (JSONL) is
JSON Lines is a format in which each line holds one JSON object. The file as a whole is not JSON, which means no trailing commas to manage and new records can be appended simply by adding a line. It is widely used wherever data flows one record at a time: application logs, machine-learning training sets, and bulk loads into BigQuery or Elasticsearch. The usual extensions are `.jsonl` and `.ndjson`.
This tool converts between JSON Lines and a JSON array in both directions. Going from JSONL to an array, blank lines are skipped and any line that is not valid JSON is reported as an error. Going the other way, the input must have an array at the top level or the conversion fails. Everything runs in your browser, so logs and training data you would rather not send anywhere stay on your machine.
How to convert between JSONL and a JSON array
- Choose the direction JSONL to JSON array, or JSON array to JSONL.
- Paste the data For JSONL, one object per line. For an array, paste the text starting with `[` as it stands.
- If an error appears, check that line The message identifies which line could not be parsed. A trailing comma or an unclosed quote is the usual cause.
- Copy the result Save the output to a file or hand it straight to whatever comes next in your pipeline.
Tips for getting more out of it
- JSON Lines (JSONL) lists one independent JSON object per line, and is the standard format for OpenAI fine-tuning datasets and log output from tools like Elasticsearch/Logstash.
- In "JSONL → JSON Array" mode, each line must be a separately parseable JSON object. Blank lines are skipped automatically.
- In "JSON Array → JSONL" mode, the entire input must be a single JSON array (`[ ... ]`). Each element in the array is output as one line of JSONL.
- Converting a large log file from JSONL to a JSON array makes it easier to work with using the `jq` command or a standard JSON array parser in your programming language of choice.
Where this conversion helps
Feeding logs to an analysis tool
Application logs written one record per line become usable by array-oriented tools and libraries once collected into a JSON array.
Preparing machine-learning data
Training sets are often distributed as JSONL while preprocessing scripts expect an array. This bridges the two.
Loading into BigQuery or Elasticsearch
Both accept newline-delimited JSON as an input format, so an array you have on hand can be converted into something they will ingest.
Making a large JSON file line-addressable
An array must be read in full before processing can start; as JSONL it can be handled one line at a time.
JSON Lines terms explained
- JSON Lines (JSONL)
- A format with one JSON value per line. **The file as a whole is not valid JSON**, because several values sit side by side. Its advantage is that each line can be read independently.
- NDJSON
- Short for Newline Delimited JSON, essentially the same thing as JSON Lines. The `.ndjson` extension comes from this name.
- Stream processing
- Handling data from the beginning as it arrives, without loading the whole of it first. JSONL suits this approach, which is why the two are so often paired.
- Top level
- The outermost value in a JSON document. Converting to JSONL requires an array `[...]` here; an object `{...}` cannot be converted.
- Blank lines
- Blank lines carry no meaning in JSONL. This tool skips them, so a stray newline at the end of a file does not break the conversion.
Frequently Asked Questions
Side Note — Why Was the "One Record per Line" Format Invented?
The JSON Lines format (also called JSONL) emerged because a standard JSON array has a fundamental limitation: you can't retrieve even a single record until the entire array has been loaded into memory and parsed. Trying to handle log data or machine learning training sets spanning millions of lines as a single JSON array meant loading the whole file into memory, which caused memory shortages and ballooning parse times for very large files.
JSON Lines solves this with a simple rule: one line equals one complete JSON object. Because a file can be read and parsed line by line as it goes, there's no need to load the entire file into memory, making it a natural fit for streaming and parallel processing. This design philosophy also lines up well with the traditional Unix "one record per line" text-processing culture — commands like `grep`, `awk`, and `sed` all operate line by line — which is a major practical advantage, since JSON Lines slots directly into existing command-line toolchains.
Today it's widely adopted as a distribution format for datasets in AI and machine learning, and it's now common for large language model training data and fine-tuning prompt/response pairs to be distributed in JSON Lines format.