JSON is the format APIs, configs and much of the modern web speak in. It's simple, but small syntax slips cause errors that are hard to spot in a compressed single-line block. This guide explains how JSON is built, how to format it to read it and how to validate it to find the bug, using the JSON formatter on this site.
What is JSON
JSON (JavaScript Object Notation) is a text format for representing structured data. It came from JavaScript, but almost every language can read and write it. Its success comes from being human-readable and easy for machines to parse. Its syntax is defined in RFC 8259.
Supported data types:
- String: text in double quotes →
"hello" - Number: integer or decimal →
42,3.14 - Boolean:
trueorfalse - Null:
null - Array: ordered list →
[1, 2, 3] - Object: key-value pairs →
{ "key": "value" }
The rules most often broken
JSON is strict. These are the errors that most often break a parse:
- Single quotes: keys and strings use double quotes, never single.
'bad'→"good". - Trailing comma:
[1, 2, 3,]is invalid. The last comma is extra. - Unquoted keys:
{ key: 1 }is JavaScript, not JSON. It must be{ "key": 1 }. - Comments: JSON does not allow comments (
//or/* */). If you need them, use a variant such as JSON5 or JSONC. - Malformed numbers: no
+1,01or.5(use0.5).
The formatter uses the browser's native JSON.parse, so it applies these same rules: whatever the browser rejects, the tool rejects too.
Formatting JSON (pretty print)
An API response usually comes minified: everything on one line, no spaces. That saves bytes but is unreadable. Formatting (or pretty print) adds line breaks and indentation so you can read the structure:
Minified:
{"user":{"name":"Ana","roles":["admin","editor"],"active":true}}
Formatted:
{
"user": {
"name": "Ana",
"roles": ["admin", "editor"],
"active": true
}
}
Much easier to inspect. You can format and validate free with the JSON formatter, which processes everything in your browser.
Validating JSON: finding the error
Validating means checking that the JSON follows the syntax. When something fails, the formatter shows the line and column where the parser stops, along with its message. That spot usually matches the error or sits just after it, so look at what comes before it too.
The typical debugging flow:
- Paste the JSON into the validator.
- If there's an error, look at the line and column it points to.
- Look for the classic problem nearby: trailing comma, single quote, unclosed brace/bracket.
- Fix and validate again.
Minifying JSON
The reverse of formatting: remove spaces and indentation to reduce size. The tool's Minify button puts the result on a single line. It's useful when you'll send the JSON over the network or store it in a config where size matters.
Why process it in the browser
The JSON you debug often contains real data: responses with user info, tokens or internal configs. A tool that formats and validates in your browser keeps that data on your machine, without passing it through a third-party server.
Frequently asked questions
What's the difference between formatting and validating? Formatting changes presentation (indentation); validating checks the syntax is correct. A good formatter does both.
Does JSON allow comments? No. For comments use JSON5 or JSONC, which are non-standard variants.
Why does my JSON fail if it "looks fine"? It's usually a trailing comma, a single quote or an unclosed brace. Use a validator that points to the line.
Is my data uploaded? No. Formatting and validation happen in your browser.
Format, validate and minify your data instantly with the free JSON formatter, 100% in your browser and uploading nothing. If you're starting from another format, see how to convert CSV to JSON.