How to format JSON
- Paste JSON into the box, or drop a .json file.
- Choose an indent (2, 4 or tab) and, if you like, Sort keys A–Z.
- Click Format or Minify. If something is wrong, the error points to the line and column.
How it works
The tool parses your JSON with its own strict parser that follows the JSON standard (RFC 8259) and reports problems in plain words: a trailing comma, single quotes, a comment, a missing colon, an unclosed string. The cursor jumps to the exact spot, so you don’t have to count characters.
It also recognises common near-JSON, such as JavaScript objects with unquoted keys or values like undefined, and tells you what to change instead of just failing.
What we measured
Formatting a 602 KB JSON file with 48,002 keys took 105 ms in Chrome on a 4-core test computer, including validation and statistics. Typical API responses and config files are done before you can blink.
When to use it
Reading an API response in one long line. Checking a config file (package.json, tsconfig, settings) before a deploy. Making test data smaller with Minify. Sorting keys so two JSON files can be compared line by line.
To compare two versions, format both here and paste them into Text & Code Diff Checker. To count characters or bytes, use Word & Character Counter.
Limits
- Comments and trailing commas (JSON5/JSONC) are reported as errors because standard JSON doesn’t allow them.
- Numbers larger than about 9 quadrillion (2^53) can lose precision when formatted, just as in JavaScript.
- Very large files (tens of MB) work but can make the page sluggish on phones.
Frequently asked questions
Is my JSON sent anywhere?
No. Parsing and formatting run in your browser, so tokens, keys and personal data in the JSON stay on your device.
What does Sort keys do?
It orders the keys in every object alphabetically. The data is unchanged; only the order differs, which makes comparing files easier.
2 spaces, 4 spaces or tab?
2 spaces is the most common in web projects, 4 in Python and Java projects. Use what your project already uses.
Why is my JSON invalid when JavaScript accepts it?
JavaScript objects allow things JSON doesn’t: single quotes, unquoted keys, comments and trailing commas. The error message tells you which one it is.