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.
Usage Tips
- 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.
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.