How to format JSON
- Paste your JSON into the input box, open a
.jsonfile, or try the example. - Choose Format for readable, indented output or Minify for the smallest size.
- Pick an indent and, if you want, sort the keys alphabetically.
- Copy the result or download it as a file.
Common JSON errors
| Mistake | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted key | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | {"a": 1} |
| Special values | {"a": undefined} | {"a": null} |
Format or minify?
Formatted JSON is for people: each value on its own line, indented to show structure, easy to read in a diff. Minified JSON is for machines: all whitespace removed, so it's smaller to store and send. Both contain exactly the same data.
Common uses
- An API response on one line. Responses from APIs and logs often arrive as one long line. Paste it in and Format turns it into indented, readable JSON.
- A config file that won't load. When an app refuses to start because of its JSON config, paste the file in to see what's wrong and where, then fix it in your editor.
- Comparing two JSON exports. Turn on Sort keys and format both versions, then compare them with the text diff tool to see what really changed.
- JSON for a single-line field. Minify removes all whitespace, which is handy for pasting JSON into an environment variable or a one-line config setting.