JSON Formatter
Paste JSON to pretty-print it, minify it or sort its keys. If it is invalid, you get the line and column of the problem and a hint for the most common mistakes.
Loading tool…
How to use the JSON Formatter
- Paste JSON into the input box.
- Choose Format or Minify, and the indentation you want. Turn on Sort keys to order object keys alphabetically.
- Fix any reported error, then copy or download the result.
Example
{"name":"Ada","skills":["math","code"],}Invalid JSON at line 1, column 40. Hint: There is a trailing comma before a closing } or ]. JSON does not allow it.
The exact error wording comes from your browser and can differ slightly between browsers.
About this tool
The formatter uses the browser’s built-in JSON.parse, a strict parser that never runs your input as code. Data stays on your device, which matters when the JSON contains API responses, tokens or personal data.
Sorting keys makes two versions of a document easier to compare in a diff. Arrays keep their order, because order is meaningful in arrays.
Known limitations
- Only strict JSON is accepted. JSON5, JSONC (JSON with comments) and JavaScript objects are reported as errors.
- Numbers beyond JavaScript's safe integer range, over 9,007,199,254,740,991, lose precision when formatted.
- Very large documents of several megabytes may make the page slow on phones.
Frequently asked questions
Is it safe to paste API responses with tokens?
The JSON is processed locally and not sent anywhere. Still, treat secrets with care: avoid pasting live production credentials into any website, and rotate tokens that may have been exposed.
Why does it reject comments?
The JSON standard does not allow comments. Files such as tsconfig.json accept them because their tools use a more permissive format called JSONC.
What is the difference between formatting and validating?
Validating checks that the text is correct JSON. Formatting rewrites valid JSON with consistent indentation. This tool validates first and only formats valid input.