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.
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
- Paste your JSON.
- Choose an indent size, or minify.
- Optionally sort keys alphabetically.
- 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.
Related tools
XML Formatter
Pretty-print XML with clean, consistent indentation. Self-closing tags and declarations are preserved, and simple text-only elements stay on one line. Instant and in-browser.
SQL Formatter
Format SQL queries for readability: keywords are uppercased and major clauses like FROM, WHERE, JOIN and ORDER BY start on new lines. String literals are left untouched. Runs in your browser.
Code Minifier
Minify JavaScript or CSS by stripping comments and unnecessary whitespace, safely preserving strings, template literals and regex. See the size saved instantly, all in your browser.
Base64 Encoder & Decoder
Encode text to Base64 or decode Base64 back to text, with a URL-safe (base64url) option. UTF-8 aware, so emoji and accented characters round-trip perfectly. Runs in your browser.