JSON explained: syntax, examples and common errors
Published by InstantToolDeck · Updated November 2026
JSON (JavaScript Object Notation) is the most common format for exchanging data between programs. APIs return it, apps store settings in it and databases export it. It is easy to read and write once you know a few rules, and easy to break if you do not.
What JSON looks like
{
"name": "Ann",
"age": 31,
"active": true,
"tags": ["admin", "editor"],
"address": { "city": "Austin", "zip": "78701" },
"manager": null
}
The building blocks
- Object: curly braces with key-value pairs. Keys are always strings in double quotes.
- Array: square brackets holding an ordered list of values.
- String: text in double quotes.
- Number: integer or decimal, with no quotes. No leading zeros, and no
NaNorInfinity. - Boolean:
trueorfalse, lowercase. - null: an explicit empty value.
The most common JSON errors
1. Trailing comma
{"a": 1, "b": 2,} is invalid. JavaScript tolerates it, JSON does not. Remove the final comma.
2. Single quotes
JSON requires double quotes for strings and keys. {'a': 'b'} will fail.
3. Unquoted keys
{a: 1} is valid JavaScript but not JSON. Write {"a": 1}.
4. Comments
Standard JSON has no comments. Remove // and /* */ or use a format that allows them, such as JSON5 or YAML.
5. Missing or mismatched brackets
Every { needs a } and every [ needs a ]. This often happens when you copy only part of a document. Formatting the text makes unbalanced brackets easy to spot.
6. Special characters in strings
Double quotes and backslashes inside a string must be escaped: "She said \"hi\"". Raw line breaks inside strings are not allowed; use \n.
Formatting, validating and minifying
Formatting (pretty-printing) adds indentation so people can read it. Minifying removes whitespace to reduce size for transfer. Validating checks that the text is legal JSON. Paste your data into the JSON formatter to do all three; the error message points to where parsing failed. If you only need a yes or no, use the JSON validator.
Working with other formats
Spreadsheet data often needs converting. The CSV and JSON converter turns tables into arrays of objects and back. To see exactly what changed between two versions of a file, use the text diff checker.
Is it safe to paste JSON into an online tool?
API responses and config files often contain tokens, emails or other private data. Use a tool that processes data locally. This site parses JSON in your browser and does not send it anywhere; see how that works.
Frequently asked questions
Can JSON have comments?
Not in standard JSON. Strip them out or use a superset like JSON5.
What is the difference between JSON and a JavaScript object?
JSON is a text format with strict rules: double-quoted keys and strings, no trailing commas, no functions or undefined.
Why does my valid-looking JSON fail?
The usual causes are trailing commas, single quotes, unquoted keys or unescaped characters inside strings.