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 checked against the JSON grammar, then its own tokens are re-printed with your chosen spacing, so numbers keep every digit, string escapes stay as written and duplicate keys are all kept. Only the whitespace changes. Syntax errors are reported by line and column, and a note appears when a value (a very long number, a duplicate key) would be changed by other JSON parsers.

Example

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

Last updated .

Frequently asked questions

What does formatting do to my JSON?

It checks your JSON and re-prints it with consistent indentation, so nested objects and arrays are easy to read. Nothing about the data itself changes: a 20-digit ID or a number like 1e400 is copied exactly, and duplicate keys are kept. Many parsers (including JavaScript’s) would round or drop those, so the tool adds a note when it sees one.

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.