JSON ↔ JSONL Converter

Convert JSON arrays to JSONL (newline-delimited JSON) and back. Shows record count and file size. One-click download. Ideal for AI/ML training datasets, log pipelines, and data exports.

JSON Array Input

JSONL Output

JSON Array

  • — Single root array wrapping all objects
  • — Human-readable with indentation
  • — Not streamable line-by-line
  • — Standard for APIs and config files

JSONL / NDJSON

  • — One JSON object per line
  • — Streamable and appendable
  • — Standard for AI/ML fine-tuning datasets
  • — Used by OpenAI, Hugging Face, LangChain

JSON vs JSONL: When to Use Each

Regular JSON arrays wrap all records inside a single structure enclosed by [ ]. This is perfect for API responses and configuration files where the entire payload is small enough to hold in memory. JSONL removes the outer array and puts each record on its own line. This enables line-by-line streaming, random-access seeking, and O(1) append operations — making it the standard format for log ingestion systems (Elasticsearch, Splunk, Datadog), data pipeline stages (Apache Beam, Spark), and machine learning dataset repositories.

AspectJSON ArrayJSONL
StreamingMust read entire fileRead line by line
Append recordRewrite fileAppend one line
Human readableYes (indented)Less (compact lines)
ML fine-tuningNot standardIndustry standard
Log storageRareVery common
API responsesStandardLess common

JSONL for AI and ML Fine-Tuning

OpenAI's fine-tuning API, Hugging Face datasets, and most LLM training frameworks require data in JSONL format. Each line represents one training example — typically a JSON object with fields like prompt and completion for older models, or a messages array for chat-format fine-tuning. Use this converter to transform a labelled JSON dataset into the JSONL format required by your training pipeline before uploading. The download button saves directly as .jsonl.

Working with JSONL in Common Tools

Most modern data tools handle JSONL natively. In Python/pandas, use pd.read_json('file.jsonl', lines=True) and df.to_json('out.jsonl', orient='records', lines=True). In the shell, jq -c '.[]' data.json converts a JSON array to JSONL. Node.js streams work perfectly with JSONL since each chunk is a complete record. DuckDB reads JSONL with read_json_auto('file.jsonl')and BigQuery supports loading JSONL files directly.

Frequently Asked Questions

What is JSONL (JSON Lines) format?

JSONL, also called JSON Lines or NDJSON (Newline-Delimited JSON), is a text format where each line contains a complete, valid JSON value — typically a JSON object. There is no wrapping array and no commas between records; newlines are the only delimiter. This makes JSONL extremely efficient for streaming, log aggregation, and machine learning pipelines because you can read, write, or append one record at a time without loading the entire file into memory.

Why is JSONL preferred for AI and ML fine-tuning datasets?

Most AI training frameworks and model fine-tuning APIs (OpenAI, Hugging Face, Axolotl, LLaMA-Factory) expect training data in JSONL format. The main reasons are: (1) JSONL files can be read line-by-line without parsing the entire file, enabling efficient streaming over large datasets. (2) Each example is independent, making it easy to shuffle, split, and sample. (3) Appending new training examples is trivial — just append a new line. (4) Tools like `jq` and pandas read JSONL natively with `read_json(lines=True)`.

What is the difference between JSONL, NDJSON, and JSON Lines?

JSONL, NDJSON (Newline-Delimited JSON), and JSON Lines are different names for the same format: one JSON value per line with newlines as delimiters. The file extension varies too — .jsonl and .ndjson are both common. The jsonlines.org specification formalises the format. Some tools and platforms use one name over another, but they are interchangeable for practical purposes. This converter accepts and produces all of them.

Can JSONL contain non-object values like arrays or strings?

Technically yes — the JSON Lines spec allows any valid JSON value per line, including strings, numbers, arrays, booleans, and null, not just objects. However, in practice almost all real-world uses of JSONL contain JSON objects (key-value maps) per line, because that is what database exports, log formats, and AI dataset schemas produce. This converter is optimised for the object-per-line use case, which covers the vast majority of scenarios.

How do I convert a JSONL file back to a JSON array?

Switch the converter to 'JSONL → JSON' mode, paste the JSONL content (one JSON object per line), and click Convert. The tool parses each line independently, validates it as valid JSON, and wraps the results in a pretty-printed JSON array. If any line fails to parse, you will see an error showing the exact line number and the parse error message so you can correct it quickly.