JSON formatter
Paste JSON to pretty-print it with the indentation you like, or minify it for transport. Invalid input is flagged immediately, and keys can be sorted so two documents are easy to diff.
Result
How to use this tool
- Paste the JSON into the box. The result appears as soon as it parses.
- Choose Pretty print with 2 spaces, 4 spaces or tabs, or Minify for a single line.
- Tick Sort keys to order object keys alphabetically at every level.
- Copy the result. The summary shows the key count, nesting depth and size in bytes.
Good to know
- Parsing uses the browser's built-in JSON parser: numbers beyond 2^53 lose precision and duplicate keys keep the last value.
- Nothing is uploaded; formatting runs entirely in your browser.
Frequently asked questions
Why does it say my JSON is invalid?
JSON is stricter than JavaScript. Keys and strings must use double quotes, trailing commas are not allowed, comments are not allowed, and values can only be objects, arrays, strings, numbers, true, false or null. A single quote, a comment line or a stray comma after the last item are the usual causes, so fix the first one you find and check again.
What does minify do?
Minify removes every space and line break between tokens so the document fits on one line, which is the smallest valid form for API calls, configuration strings and logs. It never changes values or key order, and pretty printing a minified document gives back the same data, so the two are safe to switch between.
How does sorting keys work?
Object keys are sorted in code-point order, so digits come before uppercase letters and uppercase before lowercase, and the sort is applied recursively inside nested objects. Arrays keep their order because position carries meaning. Sorted output makes two versions of a document line up in a diff tool.
Are large numbers and duplicate keys preserved?
The tool uses the browser's built-in JSON parser, so integers above 2^53 (about nine quadrillion) lose precision, a float such as 1.0 comes back as 1, and when a key appears twice only the last value survives. If you need exact big integers or IDs, keep them as strings before formatting.
How are keys, depth and bytes counted?
Keys is the total number of object keys at every level. Depth is the deepest nesting of objects and arrays, where a flat object is 1 and a lone number or string is 0. Bytes is the UTF-8 size of the output, which is what a file or an HTTP body would occupy; a Korean character counts as 3 bytes.
Results are estimates for general information. Double-check anything important with an official source.