JSON Formatter & Validator
Paste JSON to beautify it, check it for errors or minify it. Errors show the exact line and column. Click the output to edit again.
How to format and validate JSON
- Paste your JSON into the box, or click Sample to try an example.
- Click Format (or press Ctrl + Enter). Valid JSON is indented and colored: keys in red, text in green, numbers in blue, true/false in orange.
- If the JSON is not valid, the red bar shows the line and column of the first error, and the cursor jumps to that spot so you can fix it.
- Choose 2 spaces, 4 spaces or Tab for the indentation, and tick Sort keys to order every object's keys from A to Z (handy when you compare two JSON files).
- Minify removes all spaces and line breaks, which makes the JSON as small as possible for an API request or a config value. Copy and Download save the result.
Everything runs in your browser with the built-in JSON.parse. Your JSON is never sent to a server, so it is safe to paste API responses, tokens or private data.
Common JSON errors and how to fix them
JSON is stricter than JavaScript. These five mistakes cause almost every "invalid JSON" message:
| Problem | Wrong | Right |
|---|---|---|
| Trailing comma after the last item | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Keys without quotes | {name: "Ann"} | {"name": "Ann"} |
| Comments | {"a": 1 // id} | {"a": 1} |
| Values JSON does not have | undefined, NaN, 0x1F | null, 0, 31 |
Other rules: text must use double quotes, and a quote or backslash inside text is written as \" or \\; a line break inside text is \n; numbers cannot start with a zero (07) or a plus sign.
What JSON looks like
JSON (JavaScript Object Notation) is a plain-text format for data. Almost every web API, many config files (package.json, tsconfig.json, VS Code settings) and most NoSQL databases use it. It has only six kinds of values: objects in { }, arrays in [ ], strings in double quotes, numbers, true/false and null.
{
"id": 42,
"name": "Ann",
"active": true,
"tags": ["admin", "beta"],
"address": { "city": "Lisbon", "zip": null }
}
Formatting (also called "beautifying" or "pretty printing") only adds spaces and line breaks. It never changes the data, so formatted and minified JSON mean exactly the same thing.
Frequently asked questions
How do I check if my JSON is valid?
Paste it into the box and click Format. If it is valid, the status bar below the editor says "Valid JSON". If not, the red bar tells you the line and column of the first error and what is probably wrong, for example a trailing comma or a missing quote.
Is it safe to paste private data here?
Yes. The formatter runs completely in your browser. Nothing you paste is uploaded, logged or stored, and the page works offline once it has loaded.
What is the difference between Format and Minify?
Format adds line breaks and indentation so people can read the JSON. Minify removes every unnecessary space and line break so the JSON is as small as possible, which is better for sending over a network or storing in a database. Both keep the data the same.
Why does my JSON with comments show an error?
Standard JSON does not allow comments. Some tools accept "JSONC" or JSON5 (VS Code settings, for example), but JSON.parse and most APIs do not. Remove the // and /* */ parts and the JSON will be valid.
Should I use 2 spaces, 4 spaces or tabs?
It does not change the data, so use what your project uses. 2 spaces is the most common for JSON (npm, most JavaScript projects); 4 spaces is common in Python and Java projects. Pick it in the indentation menu before you click Format.
How large a JSON file can I format?
Files of several megabytes work fine in a modern browser. Very large files (50 MB and more) can make the page slow, because the whole text and its colors are kept in memory.