"category": "format-converter",

JSON Lines to JSON Converter

"tldr": Paste JSON Lines (logs, dataset exports) and get a pretty-printed JSON array - with the exact line number reported if any record is broken.

Convert JSON Lines (JSONL/NDJSON) - the one-object-per-line format used by log files, ML dataset exports, and MongoDB/BigQuery dumps - into a proper JSON array you can pretty-print, query with jq, or feed to tools that expect a single document.

{"json lines": "json array"}

Each line is parsed independently, so a corrupt record is reported with its exact line number instead of one opaque failure - which also makes this a quick validity checker for .jsonl files before you upload them anywhere.

How to convert JSON Lines to JSON

  1. 1Paste your JSONL content - blank lines are ignored.
  2. 2Each line is parsed separately; a bad line is reported by number.
  3. 3The records are wrapped into a pretty-printed JSON array.
  4. 4Copy or download - now jq, formatters, and array-based tools can handle it.

Convert JSON Lines to JSON array in code

Python
import json

with open("events.jsonl") as f:
    records = [json.loads(line) for line in f if line.strip()]
jq
jq -s '.' events.jsonl > events.json

Frequently asked questions

I got "Extra data" errors trying to parse this file - why does this tool work?

Because json.loads/JSON.parse expect one document and a JSONL file contains many - that is precisely the Python "Extra data" error. Line-by-line parsing (what this tool does) is the correct way to read JSONL; see our error guide on it for the code patterns.

Can I process huge JSONL files here?

Browser memory is the limit - tens of MB is fine. For gigabyte-scale files, stream instead: jq -s (slurp) on the command line, or line-by-line reads in code, so you never hold everything at once.

How do I do this with jq?

jq -s '.' file.jsonl - the -s (slurp) flag reads all inputs into one array. The reverse (array to lines) is jq -c '.[]' file.json.

Last updated:

You might also need

Free and in-browser, like everything on JSON Console. Browse all tools →