DataSwitch Pro Private, in-browser data converter

JSONL to JSON Converter

Turn newline-delimited JSON — logs, exports, AI training data — into a standard JSON array.

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

How to convert JSON Lines to JSON

Updated · 3 min read

JSON Lines stores one JSON value per line. It is the format of choice for log pipelines, BigQuery and Elasticsearch exports, and machine-learning datasets — including OpenAI fine-tuning files and many Hugging Face datasets. Many tools, though, expect a single JSON array. This converter validates each line and joins them into one array.

  1. Paste JSON Lines or drop a .jsonl / .ndjson file.
  2. Each line is parsed separately; an invalid line is reported with its line number.
  3. Blank lines are skipped automatically.
  4. Copy or download the resulting JSON array.

Example

JSON Lines input

{"ts": "2026-10-31T08:00:01Z", "level": "info", "msg": "server started", "port": 8080}
{"ts": "2026-10-31T08:00:07Z", "level": "warn", "msg": "slow query", "ms": 812}
{"ts": "2026-10-31T08:01:12Z", "level": "error", "msg": "db timeout", "retry": true}

JSON output

[
  {
    "ts": "2026-10-31T08:00:01Z",
    "level": "info",
    "msg": "server started",
    "port": 8080
  },
  {
    "ts": "2026-10-31T08:00:07Z",
    "level": "warn",
    "msg": "slow query",
    "ms": 812
  },
  {
    "ts": "2026-10-31T08:01:12Z",
    "level": "error",
    "msg": "db timeout",
    "retry": true
  }
]

Every line becomes one element of the array, in order. Lines do not need to share the same keys.

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

What is JSON Lines?

A JSON Lines file (also called NDJSON, newline-delimited JSON) is UTF-8 text where every line is a complete, valid JSON value — usually an object — and lines are separated by \n. Because each record stands alone, files can be streamed, appended to and split without parsing the whole file, which is why logging systems and data pipelines love it.

Errors are reported per line

In a large dataset, one broken line can be hard to find. The converter parses line by line and stops at the first invalid one with a message such as Invalid JSON on line 1,284, so you can jump straight to it in your editor. Common culprits are unescaped line breaks inside strings, truncated last lines and pretty-printed records that span several lines.

JSON Lines in AI and data work

Converting to a JSON array makes the data easy to inspect, or to turn into a table with the JSONL to CSV conversion.

Convert JSON Lines to JSON 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.jsonl", encoding="utf-8") as f:
    rows = [json.loads(line) for line in f if line.strip()]

with open("data.json", "w", encoding="utf-8") as f:
    json.dump(rows, f, indent=2, ensure_ascii=False)

Command line (jq)

jq -s '.' data.jsonl > data.json

Frequently asked questions

Are JSONL and NDJSON the same?

For practical purposes, yes. Both mean one JSON value per line, UTF-8 encoded, separated by newlines. The file extensions .jsonl and .ndjson are both accepted.

Can lines have different fields?

Yes. Each line is independent, and the resulting array keeps every object exactly as it was.

Can I convert JSON Lines to CSV or Excel?

Yes — choose CSV or Excel as the target. Keys from all lines become columns, and nested objects are flattened.

How large can the file be?

Files of tens of megabytes work in modern browsers; large inputs are processed in a background thread.

Is my dataset uploaded?

No. Everything runs in your browser, which matters for proprietary training data.

Related converters