JSON Formatter
Runs locallyBeautify, minify and sort JSON as you paste — with a tree view and search.
Input
180 B
Formatted
287 B · 2-space indent
{"id": 1042,"customer": {"name": "Ada Lovelace","email": "[email protected]"},"items": [{"sku": "KB-01","qty": 1,"price": 89.5},{"sku": "MS-07","qty": 2,"price": 24}],"paid": true,"coupon": null}Need duplicate-key and big-number checks? The JSON Validator reports them.
Formatting changes whitespace, never the data
A JSON formatter re-prints the same document with line breaks and indentation so a person can read it. Nothing about the data changes: the keys, values and array order are identical, and a machine parses the formatted and the minified versions to the same result. Minifying does the reverse and strips every optional space, which is what you want in an HTTP body or a log line where each byte counts.
Formatting only works on valid JSON, so the formatter parses first and shows the first syntax error with its line and column when it cannot. For a deeper check — duplicate keys, where the last value silently wins, or IDs too large to survive JSON.parse — open the same text in the JSON Validator. Sorting keys is useful before a diff: two payloads that differ only in key order become identical, and the real changes stand out when you compare them in the Diff Checker.
Strict JSON (RFC 8259) has no comments and no trailing commas, but many config files are really JSONC: tsconfig.json, .eslintrc.json, VS Code settings. Lenient mode blanks those out before parsing — every line and column stays where it was, so errors still point at the right place — and the output is strict JSON that any parser accepts. Numbers are kept exactly as written, so 12345678901234567890 does not come out as 12345678901234567000.
JSONC input (lenient mode)
{"name":"api",// service
"ports":[8080,8443,],}Formatted, 2 spaces
{
"name": "api",
"ports": [
8080,
8443
]
}The // comment and both trailing commas are removed; without lenient mode the first error is reported at line 1, column 15.
Where people get caught
Comments in "JSON" config files
tsconfig.json and VS Code settings accept comments; JSON.parse, jq and most APIs do not. Format with lenient mode on, and the output is safe to send to a strict parser.
Single quotes and unquoted keys
JavaScript object literals are not JSON. {name: 'api'} fails because keys and strings need double quotes. Lenient mode does not rewrite quotes, so the error points at the first one to fix.
Large integers change when re-serialised elsewhere
This formatter keeps the original digits, but a formatter built on JSON.parse rounds anything above 9007199254740991. If a formatted ID differs from the source, that is why.
Sorting keys in data where order matters
JSON objects are unordered by the spec, but some consumers read the first key specially (for example a "type" discriminator). Sort for reading and diffing, not for the payload you send.
About JSON formatting
How it works in 4 steps · 4 common use cases · 5 questions answered
About JSON formatting
How it works in 4 steps · 4 common use cases · 5 questions answered
How it works
- 1.Paste, type or drop a .json file — the output updates as soon as the input parses.
- 2.Choose Beautify with 2 spaces, 4 spaces or tabs, or Minify.
- 3.Sort keys, switch to the tree, or search keys and values.
- 4.Copy the result or download it as data.json.
Common use cases
- •Reading a minified API response or a log line
- •Normalising two payloads before a diff
- •Turning tsconfig.json or settings.json into strict JSON
- •Minifying a fixture before embedding it in a test
FAQ
Does formatting change my JSON?
Only the whitespace. Keys, values and order stay the same unless you turn on Sort keys, and numbers keep their original digits.
What is the difference between the JSON Formatter and the JSON Validator?
The formatter is output-first: it re-prints valid JSON the way you want it. The validator focuses on the input and reports duplicate keys, precision loss and the exact position of every problem.
Can it format JSON with comments?
Yes — turn on Lenient (JSONC/JSON5). Comments and trailing commas are removed and the output is strict JSON. Other JSON5 syntax, such as single quotes, is still reported as an error.
2 spaces or 4?
Either is valid. Two spaces is the common default in JavaScript projects and API docs; four is common in Python and Java codebases. Tabs keep files smallest while staying readable.
Is my JSON uploaded anywhere?
No. Parsing and formatting run in this tab, large documents in a Web Worker, and nothing is sent over the network.
Related tools
- JSON ValidatorFind duplicate keys and numbers that lose precision
- JSON Tree ViewerBrowse a large payload as a tree without the editor
- JSON Sort KeysSort keys at every level, ascending or descending
- JSON to YAMLTurn the formatted JSON into YAML config
- JSONPath EvaluatorPull one field out of the document with a $.path query
- Diff CheckerCompare two formatted documents line by line