Every modern web API returns JSON. Every configuration file you write in Node.js is JSON. Every mobile app talks to its backend in JSON. If you work with the web at all, you cannot avoid it.
The good news: JSON is very simple. It has only a handful of rules, and once you learn them, you will never struggle with it again.
What is JSON?
JSON stands for JavaScript Object Notation. It is a text-based format for storing and transmitting structured data.
Despite the name, JSON is language-independent. You can use it in Python, Ruby, Go, PHP, Rust, Java, and almost any other language. It is the standard for modern APIs.
A JSON document looks like this:
{ "name": "Alice", "age": 30, "email": "alice@example.com", "active": true }
JSON syntax rules
JSON has only a few rules, but they are strict. Unlike JavaScript, JSON does not forgive you for mistakes.
- Keys must be in double quotes.
"name", notnameor'name'. - Strings must be in double quotes. Same rule.
- No trailing commas. The last item in a list or object must not have a comma after it.
- No comments. Standard JSON does not support
//or/* */. - Values are separated by commas, key-value pairs are separated by colons.
This is the #1 mistake beginners make. In JavaScript, both
'name' and "name" are valid. In JSON, only
double quotes are valid. Single quotes will cause a parse error.
The 6 JSON data types
JSON supports exactly six data types:
1. String
Text in double quotes: "hello world"
2. Number
Integer or decimal: 42, 3.14, -1.5e10
3. Boolean
True or false (lowercase): true, false
4. Null
Explicit empty value: null
5. Array
Ordered list in square brackets: [1, 2, 3]
6. Object
Key-value pairs in curly braces: {"name": "Alice"}
That is it. No dates, no functions, no undefined, no comments. Just these six types.
Real-world examples
Example 1: A user record
{ "id": "550e8400-e29b-41d4-a716-446655440000", "username": "alice_dev", "email": "alice@example.com", "created_at": "2026-09-12T10:30:00Z", "active": true, "roles": ["admin", "user"], "profile": { "first_name": "Alice", "last_name": "Johnson", "avatar_url": "https://cdn.example.com/alice.jpg" } }
Example 2: An API response
{ "status": "success", "data": { "items": [ {"id": 1, "name": "Product A", "price": 29.99}, {"id": 2, "name": "Product B", "price": 49.99} ], "total": 2, "page": 1 } }
📝 Try the Free JSON Formatter
Format, validate, and beautify JSON in one click. No signup.
Open JSON Formatter →Common JSON errors
These are the errors you will see most often, and how to fix them:
Error 1: Trailing comma
Invalid:
{"a": 1, "b": 2,}
Valid:
{"a": 1, "b": 2}
Error 2: Single quotes
Invalid:
{'name': 'Alice'}
Valid:
{"name": "Alice"}
Error 3: Unquoted keys
Invalid:
{name: "Alice"}
Valid:
{"name": "Alice"}
Error 4: Missing comma
Invalid:
{"a": 1 "b": 2}
Valid:
{"a": 1, "b": 2}
Error 5: Comments
Invalid:
{"a": 1} // this comment
JSON does not support comments. Remove them.
How to format and validate JSON
The best way to avoid JSON errors is to use a formatter and validator. A good tool will:
- Detect syntax errors and show you the exact location.
- Pretty-print (beautify) JSON so it is readable.
- Minify JSON to reduce file size.
- Sort keys alphabetically for consistency.
Our JSON Formatter does all of these, runs entirely in your browser, and never sends your data anywhere. It is the perfect tool for debugging APIs and writing configuration files.
Frequently asked questions
What does JSON stand for?
JSON stands for JavaScript Object Notation. It is a lightweight, text-based data format used for storing and exchanging data between systems.
What is the difference between JSON and XML?
Both are data formats, but JSON is more compact, easier to read, and natively supported in JavaScript. XML has more features (attributes, namespaces, schemas) but is more verbose. Modern APIs almost universally use JSON.
Can JSON have comments?
No, standard JSON does not support comments. If you need comments in a config file, use JSON5, YAML, or TOML instead.
What causes most JSON errors?
The most common JSON errors are: trailing commas, single quotes instead of double quotes, unquoted keys, and missing commas between items. Use a JSON validator to catch these errors instantly.
Is JSON the same as a JavaScript object?
No. JSON is a subset of JavaScript object syntax. Valid JSON is also valid JavaScript, but the reverse is not true. JavaScript objects can have functions, undefined values, and unquoted keys, which are not valid JSON.
Final thoughts
JSON is simple, but its strictness catches beginners off-guard. The key is to understand the six data types and the few syntax rules, then use a good formatter to catch mistakes.
Try our free JSON Formatter - it validates, beautifies, minifies, and sorts keys, all in your browser.