JSON Formatter & Validator — Guide

Format and validate JSON online — pretty-print at your indent size, sort keys and spot syntax errors instantly, right in your browser.

What it is and when to use it

Prettifying JSON is a parse-print round trip, and that fact carries three consequences people discover the hard way. First, key order is preserved but nothing is sorted — if the input came from a system that emits keys in arbitrary order, formatting will not fix your diffs. Second, everything JSON does not have stays gone: comments are rejected at parse (not stripped — rejected), duplicate keys collapse to the last occurrence, and number precision can change when very large integers pass through a double. Third, the error message is the actual product: a column pointer into "Unexpected token , at position 412" is what makes this tool useful for config files, because hand-edited JSON breaks in predictable places — trailing commas, unquoted keys, single quotes, and the classic Chinese IME full-width comma that looks identical at a glance. Validation and formatting are the same operation here; if it formats, it parsed, which means the output is provably well-formed JSON even when the input was not.

Formats cramped JSON into a readable indented structure — essential when reading logs and API responses.

How to use it

  1. Paste the minified JSON
  2. Get the formatted result
  3. Adjust the indentation if you need to

A worked example

Fill in sample JSON

{"name":"DigDevBox","tools":["toolbox","devtools"],"count":2}

Copy this into the tool, or open JSON Formatter & Validator

Things that trip people up

  • JSON only allows double quotes; single quotes fail to parse

Questions people ask

Why does my file with comments fail?
Standard JSON has no comments — the parser rejects them rather than stripping them. Use JSONC or YAML where comments belong, or remove them before pasting.
Did formatting change my data?
Structure is preserved, but two edge cases exist: duplicate keys collapse to the last value, and integers beyond 2^53 may lose precision through the number type. Compare sizes if that matters.
Why is my diff still huge after prettifying both sides?
Because key order comes from the input, not the formatter. Sort keys explicitly (many editors offer a sort option) when comparing machine-generated JSON.
What are the most common syntax errors in hand-edited JSON?
Trailing commas, unquoted keys, single quotes, and full-width punctuation from Chinese input methods. The error position pointer usually lands right on one of these.

Next steps

Open the JSON Formatter & Validator tool

Spotted something wrong on this page? Tell us via Contact Us