DataSwitch Pro Private, in-browser data converter

JSON to JSONL Converter

Split a JSON array into JSON Lines — one compact record per line, ready for pipelines and AI tools.

Copied to clipboard!
Rows
0
Columns
0
Delimiter
—
Input Size
0 B
Output Size
0 B
Speed
0 ms

How to convert JSON to JSON Lines

Updated · 3 min read

Many data platforms want newline-delimited JSON rather than one big array: fine-tuning APIs, BigQuery loads, Elasticsearch bulk imports and streaming tools. This converter writes each element of your JSON array on its own line in compact form, with nothing else in the file.

  1. Paste a JSON array or drop a .json file. API responses like {"data": [...]} are unwrapped automatically.
  2. Each element is written on one line without extra whitespace.
  3. Check the row count to confirm the number of records.
  4. Download the .jsonl file.

Example

JSON input

[
  { "prompt": "Summarize: The meeting moved to Friday.", "completion": "Meeting now Friday." },
  { "prompt": "Summarize: Invoice #42 was paid in full.", "completion": "Invoice 42 paid." }
]

JSON Lines output

{"prompt":"Summarize: The meeting moved to Friday.","completion":"Meeting now Friday."}
{"prompt":"Summarize: Invoice #42 was paid in full.","completion":"Invoice 42 paid."}

Each object occupies exactly one line, and characters such as non-Latin letters are kept as UTF-8 rather than escaped.

Your data stays on your device. The conversion runs in JavaScript inside this tab — files and pasted text are never uploaded to DataSwitch Pro.

Formatting rules

Preparing fine-tuning data

LLM fine-tuning services expect one training example per line, typically an object with a messages array of role/content pairs. Build or clean your examples as a regular JSON array, which is easier to edit, then convert it here. Validate a few lines against the provider's documentation before uploading a large file.

Loading into BigQuery and Elasticsearch

BigQuery loads JSONL with --source_format=NEWLINE_DELIMITED_JSON. Elasticsearch's bulk API also uses NDJSON, but alternates action lines and document lines, so add the action lines (for example {"index":{}}) before each document when preparing a bulk request.

Convert JSON to JSON Lines in code

For one-off files the tool above is quickest. To automate the same task in a script or pipeline, these snippets are a good starting point.

Python

import json

with open("data.json", encoding="utf-8") as f:
    rows = json.load(f)

with open("data.jsonl", "w", encoding="utf-8") as f:
    for row in rows:
        f.write(json.dumps(row, ensure_ascii=False) + "\n")

Command line (jq)

jq -c '.[]' data.json > data.jsonl

BigQuery load

bq load --source_format=NEWLINE_DELIMITED_JSON --autodetect \
  mydataset.mytable data.jsonl

Frequently asked questions

What if my JSON is not an array?

An object wrapping a single array is unwrapped; any other object is written as one line, which is still valid JSON Lines.

Can I convert CSV or Excel straight to JSONL?

Yes. Choose CSV or Excel as the source and JSON Lines as the target.

Does it validate my data for fine-tuning?

It guarantees valid JSON on every line, but not the provider-specific structure. Check the required fields in your provider's documentation.

How do I convert back?

Use the swap button or the JSONL to JSON converter.

Is my data uploaded?

No. The conversion runs in your browser.

Related converters