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.
Troubleshooting
- “JSON does not support comments. Remove // or /* */ blocks.”
- Configuration files sometimes allow comments, but JSON does not. Remove them, or keep them in a separate notes file.
- An error points to a line that looks correct.
- The real mistake is often just before it: a missing comma or quote on the previous line, or a trailing comma after the last item. The guide on JSON errors lists the common causes.
Privacy and processing
- Where it runs
- In this browser tab, using your browser’s built-in JSON parser.
- What goes over the network
- Nothing you type or paste is sent anywhere. The result is worked out as you type, in this tab. Like every page on this site, this page also loads Google’s advertising and consent scripts, described in the Privacy Policy; the tool does not pass your files or text to them.
- Limits
- Very large JSON files (tens of megabytes) can make the page slow.
- Afterwards
- The text stays in this tab and disappears when you close or reload it. Toolora does not save it.
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.