How to use the JSON Formatter
- Paste JSON into the left panel, or drop a .json file on it.
- Formatted output appears on the right as you type; invalid JSON shows the error location.
- Choose 2 spaces, 4 spaces or tabs, and optionally sort keys alphabetically.
- Copy, download, or minify the result for production.
The JSON errors you will actually hit
| Mistake | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | JSON has no comments |
| Special values | NaN, undefined | null |
All of these are legal in JavaScript object literals but not in JSON, which is why copying an object out of source code so often fails to parse.
Formatting versus minifying
Formatting (pretty-printing) adds indentation and line breaks so people can read the structure. Minifying removes all optional whitespace to make the payload smaller — typically 10–30% for API responses. The data is identical either way; only whitespace changes.
Sorting keys is useful before comparing two JSON documents: once both are sorted and formatted the same way, the Diff Checker shows only real differences.
Frequently asked questions
Is it safe to paste API responses with tokens or personal data?
Yes. Parsing and formatting happen in your browser; nothing is sent to a server, logged or stored. You can confirm this by loading the page and then disconnecting from the internet — it keeps working.
Why does my JSON fail when it works in JavaScript?
JSON is stricter than JavaScript: keys and strings need double quotes, trailing commas and comments are not allowed, and values like undefined or NaN do not exist. The error message shows where the first problem is.
How large a file can it format?
Files of several megabytes format comfortably. Very large files (50 MB+) depend on your device’s memory.
Does formatting change my data?
No — only whitespace changes. Sorting keys changes key order, which is not significant in JSON objects, but array order is always preserved.