JSONL ↔ JSON Array Converter
100% client-side. Files stay in your browser.
Convert
JSONL ↔ JSON Array Converter
Convert JSONL / NDJSON to a single JSON array, or split a JSON array back into one-record-per-line JSONL. Useful when moving between fine-tune upload formats, API payloads, and line-delimited log streams.
Before you start
You need either a JSONL file (where each line is a standalone JSON object) or a standard JSON file containing a single array. I built this tool to be bi-directional because I often find myself needing to wrap streaming logs into a single array for a quick script, or conversely, unwrapping a giant export to feed into an LLM fine-tuning pipeline.
If you are converting JSONL → JSON array, make sure every line in your input is valid JSON. This tool is pretty forgiving and will skip empty lines, but a single malformed line will trigger an error.
There is no hard file size limit since everything happens in your browser's memory. For files over 100 MB, I recommend setting the indent to 0 to avoid the massive memory overhead of generating a pretty-printed string that might crash your tab.
How to use it
- Paste your data into the Input pane, or drag and drop a
.jsonlor.jsonfile directly onto the page. - Adjust the Indent value — use
2or4for readability, or0for a compact, minified result. - Click JSONL → JSON array to wrap lines into a single
[...]block, or JSON array → JSONL to unwrap an array into line-delimited objects. - Check the status bar at the bottom to see the record count or any parsing errors.
- Use Copy to grab the text or Download to save the result as a file.
Options explained
Indent
This controls the JSON.stringify indentation level. When converting to a JSON array, it creates a pretty-printed structure that is easy for humans to read. When converting to JSONL, it applies that same indentation to each individual line. Usually, for JSONL, you want this at 0 to keep every record on exactly one line, which is what most APIs expect.
The Conversion Buttons
Because this tool works both ways, you have to tell it which direction to go. JSONL → JSON array looks for lines of text and wraps them. JSON array → JSONL parses the entire input as one big JSON blob, verifies it's an array, and then iterates through the items to write them out line-by-line.
Example
Input (JSONL):
{"id": 101, "status": "ok"}
{"id": 102, "status": "error"}
Output (JSON array, Indent: 2):
[
{
"id": 101,
"status": "ok"
},
{
"id": 102,
"status": "error"
}
]
Tips & common pitfalls
- Empty lines are ignored. When going JSONL → JSON, I skip whitespace-only lines so you don't get
nullentries in your array. - Key order is preserved. Modern JavaScript engines maintain the insertion order of string keys, so your objects won't be "shuffled" during the round trip.
- Nested arrays are fine. If your JSONL contains arrays instead of objects, the tool handles them perfectly. The only requirement is that each line is valid JSON.
- Large files and Indent. If you are converting a 50 MB file and use an indent of 2, the resulting string can easily double or triple in size due to the extra whitespace. Use
0for big datasets.
Troubleshooting
I get an "Unexpected token" error when converting JSONL.
This means one of your lines isn't valid JSON. Check for trailing commas at the end of lines, or lines that contain raw text instead of a JSON object. Use the JSONL Validator to find exactly which line is broken.
The "JSON array → JSONL" button doesn't do anything.
Make sure your input starts with [ and ends with ]. If the input is just a single object (starts with {), there is no array to split, so the tool won't produce multiple lines.
My browser tab crashed or froze.
This usually happens when trying to "Pretty-print" a massive file. Refresh the page, paste your data again, but set the Indent to 0 before clicking convert. This uses much less memory.
Related tools
See also: if you need to do something adjacent on this site, try JSONL to CSV to flatten JSONL into a CSV with dotted keys, Formatter to pretty-print or minify each JSONL record, or OpenAI Fine Tune Validator to validate an OpenAI fine-tune file against the chat schema.
Frequently asked questions
What is the difference between JSONL and NDJSON?
Functionally, nothing. JSONL (JSON Lines) and NDJSON (Newline Delimited JSON) are two names for the same thing: a file where every line is a valid JSON value. This tool handles both.
Does this support trailing commas in the JSON array?
No. Standard JSON.parse() is used, which follows the strict JSON spec. If your array has a trailing comma after the last item, it will fail to parse. Clean that up first!
Is there a limit on how many lines I can convert?
The only limit is your computer's RAM. Since the tool has to hold the input and the output strings in memory simultaneously, I'd suggest sticking to files under 200 MB for a smooth experience.
Are my files uploaded to a server?
Never. I value my own privacy, so I built this to run entirely in your browser. The data you paste never leaves your machine. You can even use this page offline if you've loaded it once.
How can I do this via the command line?
The best tool for this is jq. To go from a JSON array to JSONL: jq -c '.[]' input.json. To go from JSONL to an array: jq -s '.' input.jsonl.