JSON (JavaScript Object Notation) is the most common format for sending data between websites, apps and APIs. It is easy to read, but it is strict: a single misplaced comma or quote makes the whole document invalid. This guide covers the rules and the mistakes behind most parse errors.
What JSON looks like
{
"name": "Asha",
"age": 29,
"active": true,
"skills": ["design", "writing"],
"address": { "city": "Pune", "pin": "411001" },
"manager": null
}
A JSON document is built from objects (curly braces with key-value pairs), arrays (square brackets with a list of values) and simple values.
The six value types
- String: text in double quotes, such as "hello".
- Number: 42, 3.14 or -7. No quotes, no leading zeros.
- Boolean: true or false, in lowercase.
- Null: null, in lowercase.
- Object: unordered key-value pairs in curly braces.
- Array: an ordered list in square brackets.
The mistakes that cause most errors
Trailing commas
A comma after the last item, such as {"a": 1,}, is allowed in JavaScript but not in JSON. Remove it.
Single quotes
JSON requires double quotes. {'name': 'Asha'} is invalid; it must be {"name": "Asha"}.
Unquoted keys
In JSON, every key must be a quoted string. {name: "Asha"} is a valid JavaScript object but not valid JSON.
Comments
JSON has no comment syntax. Lines starting with // or blocks in /* */ will break parsing. Remove them or keep notes in a separate field.
Special values
NaN, Infinity and undefined are not valid JSON. Use null or a string instead.
Unescaped characters inside strings
A double quote inside a string must be written as \", and a line break as \n. Raw tabs and newlines inside a string are not allowed.
Mismatched brackets
Every { needs a }, and every [ needs a ]. In long documents, formatting with indentation makes missing brackets obvious.
Format, minify and validate
Formatting (pretty-printing) adds indentation and line breaks so people can read the structure. Minifying removes all unnecessary whitespace to make the data smaller for transfer. Validating checks that the text follows the rules. Our JSON Formatter does all three in your browser and points to the position of an error, so you can fix it without scanning the whole file.
Tips for working with JSON
- Use clear, consistent key names, such as camelCase or snake_case, but not both.
- Store dates as ISO 8601 strings, like "2026-11-08", to avoid ambiguity.
- Keep numbers as numbers. Wrapping them in quotes turns them into strings and can break calculations.
- Do not paste confidential data into online tools you do not trust. Ours runs locally in your browser.
When data is binary
JSON cannot hold raw binary data such as an image. Such data is usually converted to text first with Base64. See our guide to Base64 encoding to learn when that is a good idea and when it is not.
Frequently asked questions
Can JSON have comments?
No. Standard JSON has no comment syntax. Remove comments, or use a format made for configuration files, such as YAML or JSONC, if your tools support it.
What is the difference between JSON and a JavaScript object?
JSON is a text format with strict rules, such as double-quoted keys and no trailing commas. A JavaScript object is a live data structure in code with more flexible syntax.
Why does my JSON show an "Unexpected token" error?
The parser met a character it did not expect, usually a trailing comma, single quote, missing comma or extra bracket near the reported position. Paste the text into a formatter to see the exact spot.