When to use it
The JSON formatter turns hard-to-read JSON into neatly indented text, checks that it’s valid, and points to the exact line and column of any error. Use it when an API returns one long unreadable line, when a configuration file won’t load, when you need to inspect a webhook payload, or when you want the smallest possible version of a file for production.
How to format JSON
- Paste your JSON into Your JSON, press Open file to load a .json file, or press Example to try it out.
- Choose Format to make it readable or Minify to make it compact.
- For formatting, pick the Indentation: 2 spaces, 4 spaces or Tabs.
- Tick Sort keys A–Z to put object keys in alphabetical order.
- Read the Result, then press Copy result or Download .json.
If the JSON isn’t valid, you’ll see where the problem is and a hint about what’s wrong.
A worked example
An API sends back this single line:
{"user":{"name":"Ana","roles":["admin","editor"],"active":true}}
With Format and 2 spaces, the result shows user on its own line with name, roles and active indented beneath it, and each role on a separate line, so the structure is clear at a glance. Now suppose you’d typed "active":true,} with a stray comma. The tool reports the line and column of the problem and suggests that there may be a trailing comma before a closing bracket.
Common JSON errors and fixes
- Trailing comma:
[1, 2, 3,]is invalid; remove the last comma. - Single quotes:
{'name': 'Ana'}must be{"name": "Ana"}. - Unquoted keys:
{name: "Ana"}needs quotes aroundname. - Missing brackets: every
{needs a}and every[needs a]. - Special values:
undefined,NaNand dates aren’t JSON; usenull, numbers or strings.
Tips
- Use 2 spaces for most projects; it’s the most common style.
- Minify only for machines. Keep a formatted copy for editing.
- Sort keys before comparing two versions of a config file.
- Very large files (tens of megabytes) may be slow on phones; use a computer.
Common mistakes
- Pasting JavaScript objects rather than JSON; JavaScript allows things JSON doesn’t, like comments and single quotes.
- Copying from a web page or chat app, which can turn straight quotes into curly “smart” quotes.
- Assuming valid JSON means correct data. The formatter checks syntax, not whether the values make sense.
Related tools
Convert JSON for spreadsheets with JSON to CSV, go the other way with CSV to JSON, or encode data for URLs with the Base64 Encoder and Decoder.