Format and validate JSON online
JSON (JavaScript Object Notation) is the standard format for APIs, config files and data exchange. Responses from APIs are usually minified onto one line, which makes them hard to read. This JSON formatter adds indentation and line breaks, and the validator tells you exactly where a syntax error is.
How to use the JSON formatter
- Paste your JSON into the left box.
- Click Beautify to format it, Minify to compress it, or Sort keys to order object keys alphabetically.
- Click Validate to check the syntax. Errors show the line and column.
- Copy or download the result.
Common JSON errors and how to fix them
- Trailing commas –
{"a": 1,}is invalid. Remove the last comma. - Single quotes – JSON needs double quotes:
"name", not'name'. - Unquoted keys –
{name: "x"}must be{"name": "x"}. - Comments – standard JSON does not allow
//or/* */comments. - Special values –
undefined,NaNand functions are not valid JSON.
Beautify or minify?
Beautified JSON is easy to read and debug. Minified JSON removes all spaces and line breaks for the smallest size, which is best for production APIs and storage. Your data stays in your browser, so it is safe to paste API responses and config files. For web code, try the HTML minifier and CSS minifier.
Before and after
Minified:
{"user":{"id":42,"name":"Sara","roles":["admin","editor"]},"active":true}
Beautified:
{
"user": {
"id": 42,
"name": "Sara",
"roles": ["admin", "editor"]
},
"active": true
}
JSON syntax rules in brief
- Data is written as key/value pairs:
"name": "Sara". - Keys and string values use double quotes.
- Allowed values: string, number,
true,false,null, object{}and array[]. - Items are separated by commas, with no comma after the last item.
Features
- Beautify with 2 spaces, 4 spaces or tabs.
- Minify to the smallest size for APIs and storage.
- Sort keys alphabetically at every level, making two JSON files easy to compare.
- Validate with clear errors that include the line and column. See the JSON validator guide for common fixes.
- Download the result as a
.jsonfile.
Common uses
Reading API responses, editing configuration files for apps and plugins, preparing test data, checking webhooks, and reviewing JSON-LD structured data before adding it to a website. Because everything runs in your browser, it is safe to paste JSON containing tokens or customer information.
Frequently asked questions
Why is my JSON invalid?
The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys and comments. The validator shows the line and column of the first error.
Is my JSON data sent anywhere?
No. Formatting and validation happen in your browser, so API keys and private data stay on your device.
What is the difference between beautify and minify?
Beautify adds indentation and line breaks for readability. Minify removes all unnecessary whitespace for the smallest size.
Can I choose the indentation?
Yes. Choose 2 spaces, 4 spaces or tabs before clicking Beautify.
