JSONL Formatter
JSONL formatter. Pretty-print each record with a configurable indent, or minify everything back down to one record per line. Up to 1 GB, runs in your browser, nothing uploaded.
100% client-side. No upload.
Format
JSONL Formatter
Pretty-print each line of a JSONL file with a configurable indent, or minify it back down. Useful for eyeballing a small dataset without pulling it into an editor.
What this tool does
It parses a JSONL / NDJSON file one line at a time and re-serialises each record two ways. Pretty print expands every object across multiple lines with the indent you choose, so you can actually read it. Minify collapses each object back to a single compact line — the canonical JSONL shape. Either way, the parse-and-reserialise step also normalises your JSON: it rewrites numbers, strips insignificant whitespace, and proves each record is valid along the way. It all happens in your browser; nothing is uploaded.
The intent here is small but constant: "I have a JSONL file and I need to read it, or I need to flatten a pretty file back to one line per record." The downstream is usually your own eyes during debugging, a code review, or prepping a file for a loader — OpenAI/Anthropic fine-tune uploads, BigQuery, Spark — all of which require one record per line.
When you'd reach for it
- Eyeball a record without an editor. Paste a few lines, hit Pretty print at indent 2, and read the structure top to bottom.
- Flatten a pretty file back to JSONL. Someone handed you a "JSONL" file where each object spans many lines — click Minify to make it one-object-per-line again.
- Pre-flight before a fine-tune or warehouse upload. Minify first; pretty-printed records break OpenAI, Anthropic, BigQuery, and Spark loaders that expect a single line per record.
- Prove a file is well-formed. Any line that won't parse is listed and skipped, so a clean run is a quick validity check.
- Normalise whitespace and number formatting. Round-tripping through the parser produces consistent, canonical JSON regardless of how the input was spaced.
- Shrink a file for transport. Minify drops every byte of insignificant whitespace before you commit or send the file.
How formatting works
Both buttons run the same pipeline; only the final serialisation differs.
Parse line by line
The input is split into lines and each non-empty line is parsed as a standalone JSON value. Blank lines are skipped silently — the spacing between records never produces an "invalid JSON" error. A line that fails to parse is added to the error list with its line number and skipped; the rest of the file still formats. The status bar reports how many records were formatted and how many bad lines were skipped.
Pretty print
Each object is re-serialised with the chosen indent and the records are joined with a blank line between them. That blank line is purely visual — it makes records easy to tell apart on screen. The important consequence: pretty-printed output is not valid JSONL. It's for humans only. Minify it before any machine reads it.
Minify
Each object is re-serialised with no whitespace and the records are joined with a single newline — one compact object per line, exactly what NDJSON parsers expect. This is the mode that produces a file you can upload or ingest.
Options reference
Indent
The number of spaces used for each nesting level in Pretty print mode, from 0 to 8. Two or four is conventional. It has no effect on Minify. Note that an indent of 0 produces compact objects with no internal whitespace at all — pretty mode at indent 0 gives you minified objects separated by blank lines, not "newlines between every key". Tabs aren't an option; the underlying serialiser only takes a number of spaces. If you need tab indentation, run a find-and-replace on the output.
Pretty print vs. Minify
These are the two actions, not a toggle. Pretty print is for reading and manual editing; its output spans many lines per record and is not loadable. Minify is for machines; its output is one record per line and is the format every JSONL consumer expects. The rule of thumb: pretty to look, minify to ship.
Output format
- Pretty print: each record indented across multiple lines, records separated by a blank line. Human-readable, not valid JSONL.
- Minify: one compact object per line, joined by single newlines, with a trailing newline. Valid JSONL / NDJSON.
- Key order: preserved as JSON insertion order (a standard JavaScript quirk applies — purely integer-like keys are emitted in numeric order, not insertion order).
- Encoding: UTF-8. Non-ASCII characters are preserved unless they were already escaped in the source.
- Download: file is named
formatted.jsonlwith MIME typeapplication/x-ndjson.
Example
Input (minified JSONL):
{"id":1,"user":"alice","meta":{"v":1}}
{"id":2,"user":"guest","meta":{"v":1}}
Output (Pretty print, indent 2):
{
"id": 1,
"user": "alice",
"meta": {
"v": 1
}
}
{
"id": 2,
"user": "guest",
"meta": {
"v": 1
}
}
Note the blank line between the two records. It's there to separate them visually and disappears the moment you Minify — but it's also why this output can't be fed straight into a JSONL parser.
Recipes by intent
Make a file readable for review
Indent 2, click Pretty print. Copy the result into a PR description or a chat — just don't commit it as the data file.
Fix a "JSONL" file that's actually pretty-printed
Paste it and click Minify. Each multi-line object collapses to a single line. If a record spans multiple lines in the input, see the troubleshooting note below — this tool parses one line at a time.
Prepare a fine-tune or warehouse upload
Always Minify last. Then validate with the OpenAI / Anthropic validator, or load into BigQuery / Spark, which all require one record per line.
Use it as a quick validity check
Run Minify and watch the status bar. "Formatted N record(s)." with no skips means every line parsed. Any "bad line(s) skipped" count points you at records to fix — the validator will show exactly where.
Limits and performance
- Memory-bound. Input, parsed records, and output all sit in browser memory at once. ~500 MB is a reasonable desktop ceiling; ~100 MB on a phone or low-RAM laptop.
- The textarea is the bottleneck. Past ~50 MB of rendered output the pane can lag. Use Download instead of Copy for large files.
- Gigabyte-scale logs belong on the CLI.
jq -c .minifies streaming JSONL, andjq .pretty-prints, both without holding the whole file in memory.
Errors and how to fix them
Line N: invalid JSON — Unexpected token …
That line isn't standalone valid JSON. The most common cause is pasting a JSON array (starts with [) or a record that's already pretty-printed across several lines — this tool parses one line at a time, so a multi-line record reads as several broken fragments. Minify the source elsewhere first, or convert an array with JSONL ↔ JSON.
Every line shows an error
You almost certainly pasted a single pretty-printed JSON document or a JSON array rather than line-delimited JSON. Each physical line must be a complete JSON value on its own. Use JSONL ↔ JSON Array to turn an array into lines first.
The Copy button does nothing on a big file
The clipboard API struggles with very large strings. Use Download to write the output straight to a file instead.
My pretty output won't load into the database / fine-tune API
Pretty print is for humans — it spreads each record over many lines and inserts a blank line between records. Click Minify to get one record per line, which is the only shape JSONL consumers accept.
The blank lines between my pretty records look wrong
They're intentional — one blank line separates each formatted record so they're easy to tell apart on screen. They vanish entirely when you switch to Minify.
FAQ
Is pretty-printed JSONL still valid for production?
No. The JSONL / NDJSON convention requires each record to be a single line. Pretty mode is strictly for reading; Minify for machines.
Can I indent with tabs?
Not currently — the serialiser takes a number of spaces (0–8). If you need tabs, run a find-and-replace on the output afterwards.
Does it preserve key order and Unicode?
Key order is preserved as JSON insertion order, with the usual JavaScript caveat that purely integer-like keys sort numerically. Non-ASCII characters (emoji, non-Latin scripts) are kept as-is unless they were already escaped in the source.
Is my data sent to a server?
Never. Everything runs in your browser's JavaScript engine, which makes it safe for sensitive logs or private training data. See the privacy policy.
What's the difference between JSONL and NDJSON?
For almost every use case, none. Both are a stream of JSON objects separated by newlines. JSONL is the common name; NDJSON (Newline-Delimited JSON) is the same idea under a different label.