Spreadsheet & CSV Tools

JSON Lines Formatter

Tidy up JSON Lines files such as logs, event streams and machine-learning datasets. Every valid line is rewritten as one compact JSON record, blank lines disappear, keys can be sorted and duplicate records removed, and invalid lines are reported with their line numbers or dropped. Switch to a readable view to inspect records, or turn the whole file into a JSON array.

  • Runs in your browser
  • No sign-up
  • Free to use

How to use JSON Lines Formatter

  1. Paste JSON Lines or open a .jsonl or .ndjson file.
  2. Choose compact, readable or JSON array output.
  3. Tick sorting, de-duplication or dropping of invalid lines.
  4. Copy or download the result.

JSON Lines Formatter features

Compact records

Exactly one JSON value per line, as the format requires.

Error reporting

Line number and reason for every invalid line.

Clean-up

Removes blank lines, duplicate records and the byte-order mark.

Sorted keys

Consistent key order for diffs and reviews.

Three views

Compact JSONL, readable records or a JSON array.

Local

Formatting happens in your browser.

When to use JSON Lines Formatter

  • Normalising a JSONL dataset before training or evaluating a model.
  • Cleaning application logs written as NDJSON.
  • Turning an export with blank lines and stray errors into a valid file.
  • Reading a long event line by line in a readable form.

JSON Lines Formatter FAQ

What is JSON Lines?

A text format where every line is a complete JSON value, usually an object. It is also called JSONL or newline-delimited JSON (NDJSON) and is popular for logs, streams and datasets because it can be read and appended one line at a time.

Why must each record be on one line?

Readers split the file at line breaks and parse each line separately. A record spread over several lines cannot be read, which is why the readable view is only for inspection.

What happens to invalid lines?

By default the first error is shown with its line number. Tick “Drop invalid lines” to keep only valid records; the number dropped is reported.

Can it read a JSON array?

Yes. A JSON array is converted to one record per line.

Does sorting change the data?

No. Key order has no meaning in JSON objects; sorting only makes files easier to compare.

Is my file uploaded?

No. The formatter runs in your browser.

Working with JSON Lines

JSON Lines solves a practical problem with JSON: a single JSON document must be read completely before it can be used, while logs, streams and large datasets grow line by line. Putting one JSON value on each line allows programs to process files of any size in a streaming way, append records without rewriting the file and split work between processes at line boundaries.

The format is simple but strict. Each line must be a complete JSON value, lines are separated by a newline, and the file is UTF-8. Real files often break these rules: pretty-printed records spread over several lines, blank lines, a stray trailing comma copied from JavaScript, a byte-order mark added by an editor, or a corrupted line from an interrupted write.

The formatter parses each line on its own. Valid records are re-serialised in compact form, which also normalises spacing and escapes; blank lines and the byte-order mark are removed. Invalid lines are reported with their line number and the reason, using the same strict JSON scanner as the other JSON tools, so problems such as a trailing comma are named precisely.

Optional clean-up steps help with datasets. Sorting keys gives every record the same key order, which makes diffs smaller and files easier to scan. Removing duplicate records compares complete records after formatting, so the same event written twice disappears. Dropping invalid lines produces a usable file from a partly corrupted one, with a count of what was removed.

For reading, the readable view prints each record indented with a blank line in between, and the JSON array view turns the file into a regular JSON document that other tools can open. Use the compact view when saving, because only that keeps the file valid JSON Lines.

Other useful tools