JSON formatter
Pretty print, minify and check JSON instantly.
Runs in your browser. Nothing you type is sent anywhere.
- Exact error location
- Collapsible tree view
- Nothing uploaded
How to format JSON
- Paste or upload your JSON.
- Choose pretty print or minify, and an indent size.
- Copy or download the result.
Pretty print vs minify
| Pretty print | Minify | |
|---|---|---|
| Whitespace | Adds indentation and line breaks | Removes all of it |
| File size | Larger, easier to read | Smallest possible, same data |
| Best for | Editing and debugging | Production APIs and storage |
Common JSON errors and how to fix them
| Error | Fix |
|---|---|
| Trailing comma before } or ] | Remove the last comma in the list |
| Single quotes around a string | Switch to double quotes only |
| An unquoted property name | Wrap every key in double quotes |
| A // or /* comment | Remove it; JSON has no comment syntax |
| Missing closing bracket or brace | Count your matching { } and [ ] pairs |
| A number like 1. or .5 | Write 1.0 or 0.5; JSON needs digits on both sides of the decimal point |
| A raw line break inside a string | Escape it as \n, since a literal newline inside quotes is not allowed |
JSON syntax rules, from RFC 8259
- A number cannot have a leading zero (01 is invalid) or a bare trailing decimal point (1. is invalid).
- Every key must be a string in double quotes. JavaScript's unquoted keys and shorthand properties are not valid JSON.
- The only literals allowed outside quotes are true, false and null, all lowercase.
- A string can only use double quotes; single quotes and backticks are JavaScript features JSON does not include.
- Duplicate keys in one object are technically allowed by the grammar, but most parsers, including this one, keep only the last value, so avoid relying on both being read.
JSON formatter FAQ
Why does my JSON show an error at a line that looks fine?
The parser reports where it gave up, which is often one character after the real mistake, such as a missing comma on the line above. Check the line just before the one shown too.
What does sort keys do?
It reorders every object's keys alphabetically before printing, which makes it easier to diff two JSON files or find a specific field.
Can I format very large JSON files?
Yes, but the collapsible tree view only builds for input under 300 KB. Larger files still format and minify, just without the tree.
What is the difference between minify and pretty print?
Pretty print adds line breaks and indentation for reading. Minify removes all of that to make the file as small as possible for production.
What does the JSON standard, RFC 8259, actually require?
It defines JSON's exact grammar: objects and arrays, strings in double quotes, numbers without leading zeros, and the literals true, false and null. Anything outside that grammar, like a comment or a trailing comma, is invalid JSON even though some parsers quietly accept it.
Can I format JSON5 or JSONC files that allow comments?
No. Comments and trailing commas, common in JSONC config files used by some editors, are not valid JSON and are reported as errors here. Strip them out first if you are working with one of those relaxed formats.
Can I expand every node in the tree view at once?
Yes, click Expand all. Large documents start with only the first level or two open to stay fast; Expand all opens every remaining node on demand.
Can I download the formatted result as a file?
Yes. The Download button saves the current output, pretty printed or minified, as a .json file, named after the file you uploaded or "formatted.json" if you pasted the text directly.