JSON Formatter

Pretty-print, validate and minify JSON, with selectable indentation and optional recursive key sorting. Syntax errors are pinpointed by line and column. Fast and private, all in your browser.

Output

Format, validate and minify

Format re-prints your JSON with consistent indentation so nested objects and arrays are easy to scan. Minify strips every optional space and newline for the smallest possible payload. Sort keys reorders object keys alphabetically (recursively) which makes two JSON files line up cleanly in a diff. Any syntax error is reported with its line and column.

All formatting happens in your browser; nothing is uploaded.

What this does

A JSON formatter parses JSON and re-prints it with consistent indentation so it is easy to read, and can also validate and minify it.

How to use it

  1. Paste your JSON.
  2. Choose an indent size, or minify.
  3. Optionally sort keys alphabetically.
  4. Copy the formatted result.

How it works

The text is parsed into a data structure and serialized back with your chosen spacing, the data itself never changes, only the whitespace. Syntax errors are reported by line and column.

Example

The object {"b":2,"a":1}, formatted with sorted keys, prints across multiple lines with “a” before “b”.

Sources & methodology

Last updated .

Frequently asked questions

What does formatting do to my JSON?

It parses your JSON and re-prints it with consistent indentation, so nested objects and arrays are easy to read. Nothing about the data itself changes.

How does key sorting work?

When enabled, every object has its keys reordered alphabetically, recursively through all nested objects, which makes two JSON files easy to compare.

Why does it say my JSON is invalid?

The parser stops at the first syntax error (a trailing comma, a missing quote or bracket) and reports the line and column so you can fix it.

Is my JSON uploaded?

No. Formatting and validation run entirely in your browser; nothing is sent anywhere.