JSON formatter
Make messy or one-line JSON readable, check whether it's valid, or shrink it for production. Paste JSON from an API response, a config file or a log, and format it with your choice of indent, minify it to one line, or sort its keys. If something's wrong, you'll see the error with its line and column.
How to use the JSON formatter
- Paste your JSON into the input box, or press Load a sample to try it.
- Press Format to pretty-print it, Minify to remove all spaces, or Validate only to just check it.
- Choose the indent (2 spaces, 4 spaces or a tab) and tick Sort keys A to Z if you want ordered keys.
- If there's an error, fix the spot shown in the message and try again.
- Copy the result or download it as a .json file.
How it works
The tool uses your browser's built-in JSON parser, which follows the official JSON standard (RFC 8259) exactly. Your data is never sent to a server, so it's safe to paste API keys or customer data, though it's still good practice to remove secrets.
Common JSON errors and fixes
| Problem | Wrong | Right |
|---|---|---|
| Single quotes | {'a': 1} | {"a": 1} |
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Keys without quotes | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | Remove the comment |
| Special values | undefined, NaN | Use null |
Minify removes every unnecessary space and line break, which makes files smaller to send. Format adds indentation so humans can read it. Both keep exactly the same data.
Example
Input: {"name":"EMI calculator","free":true,"tags":["loan","finance"]}
Formatted with 2 spaces it becomes a neat block with one key per line, and the status line shows Valid JSON · 3 keys · 2 levels deep.
Frequently asked questions
How do I find the error in my JSON?
Press Validate only. The message shows what went wrong and the line and column where the parser stopped. The real mistake is usually just before that spot, often a missing comma or quote.
Is my JSON uploaded anywhere?
No. Everything happens in your browser. Nothing is stored or sent.
What's the difference between formatting and minifying?
Formatting adds line breaks and indentation for reading. Minifying removes them to make the file as small as possible. The data is identical.
Can JSON have comments?
No, standard JSON doesn't allow comments. Some tools accept them (as JSONC or JSON5), but they must be removed for strict JSON.
Why sort keys?
Sorted keys make it easier to compare two JSON files or spot a missing field. JSON objects have no required order, so sorting doesn't change the meaning.
Last updated: 25 October 2026