What Is JSON and How to Format, Validate, and Debug It
JSON (JavaScript Object Notation) is the most widely used data format for web APIs, configuration files, and data exchange between services. Whether you're a developer debugging an API response or a non-technical user trying to read a JSON file, this guide covers everything you need.
What Is JSON?
JSON stands for JavaScript Object Notation. Despite the name, JSON is language-independent β it's used in Python, Ruby, Java, Go, PHP, Swift, and virtually every modern programming language, not just JavaScript.
JSON represents structured data as human-readable text. It was designed to be easy for both humans to read and machines to parse. Here's a simple JSON example:
{
"name": "Alice",
"age": 28,
"isActive": true,
"tags": ["developer", "designer"],
"address": {
"city": "Jakarta",
"country": "Indonesia"
}
} JSON Data Types
JSON supports exactly six data types:
| Type | Example | Notes |
|---|---|---|
| String | "Hello World" | Must use double quotes, not single |
| Number | 42 or 3.14 | No quotes; integer or float |
| Boolean | true or false | Lowercase only β not True/False |
| Null | null | Represents absence of value |
| Object | {"key": "value"} | Key-value pairs in curly braces |
| Array | [1, 2, 3] | Ordered list in square brackets |
Most Common JSON Syntax Errors
JSON syntax is strict. A single character out of place breaks the entire document. Here are the most frequent mistakes:
1. Trailing comma
β Invalid
{"name": "Alice","age": 28,}β Valid
{"name": "Alice","age": 28}JSON does not allow a comma after the last item in an object or array. JavaScript objects do, which causes confusion.
2. Single quotes instead of double quotes
β Invalid
{'name': 'Alice'}β Valid
{"name": "Alice"}All JSON strings β both keys and values β must use double quotes.
3. Unquoted keys
β Invalid
{name: "Alice"}β Valid
{"name": "Alice"}Unlike JavaScript objects, all keys in JSON must be quoted strings.
4. Comments
β Invalid
{"name": "Alice" // the user's name}β Valid
{"name": "Alice"}JSON does not support comments. Remove them before parsing.
How to Format (Beautify) JSON
Minified JSON (all on one line, no spaces) is efficient for transfer but impossible to read. Formatting β also called beautifying or pretty-printing β adds indentation and line breaks to make the structure clear.
Our JSON Formatter can beautify or minify any JSON instantly. Paste your JSON, choose an indentation level, and click Format. It also highlights syntax errors so you can find and fix problems before using the data.
For minifying JSON (removing all unnecessary whitespace to reduce file size), use our JSON Minifier.
How to Validate JSON
Validating JSON means checking that it follows the specification β correct syntax, matching brackets, no trailing commas, properly quoted strings, etc. Invalid JSON will cause a parse error in any programming language.
Use our JSON Validator to check whether any JSON string is valid. It shows the exact line and character position of any error found.
Free JSON developer tools