Every JSON value type, object and array syntax, nesting rules, and the most common syntax mistakes that break valid-looking JSON.
The complete JSON syntax in one page: the six value types, nesting rules, and the mistakes that break valid-looking JSON most often. Paste anything questionable into the JSON Formatter & Validator to check it instantly.
| Type | Example | Notes |
|---|---|---|
| String | "hello" |
Always double-quoted, never single-quoted. |
| Number | 42, 3.14, -7 |
No quotes. No leading zeros (e.g. 0123 is invalid). |
| Boolean | true, false |
Lowercase, unquoted. |
| null | null |
Lowercase, unquoted. Represents “no value.” |
| Object | {"key": "value"} |
Unordered key/value pairs, keys always double-quoted strings. |
| Array | [1, 2, 3] |
Ordered list of any JSON values, including mixed types. |
An object is a comma-separated list of "key": value pairs inside curly braces:
{"name": "Ava", "age": 29, "active": true}
An array is a comma-separated list of values inside square brackets, in a fixed order:
["red", "green", "blue"]
Array elements don’t have to be the same type: [1, "two", true, null] is valid JSON.
Objects and arrays can contain other objects and arrays, to any depth:
{"user": {"name": "Ava", "roles": ["admin", "editor"]}}
| Mistake | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1, "b": 2,} |
{"a": 1, "b": 2} |
| Single-quoted strings | {'a': 'b'} |
{"a": "b"} |
| Unquoted keys | {a: 1} |
{"a": 1} |
| Comments | {"a": 1 // note} |
JSON has no comment syntax at all |
| Leading zero | {"n": 007} |
{"n": 7} |
| NaN / undefined | {"n": NaN} |
{"n": null} |
JSON Formatter & Validator
No. Standard JSON has no comment syntax at all — not //, not /* */. Some tools accept a relaxed superset (JSON5, JSONC), but plain JSON parsers will reject them.
No. JSON objects are unordered collections of key/value pairs — most parsers preserve insertion order in practice, but the JSON specification itself does not guarantee or require it.
Yes. An array like [1, "two", true, null, {"a": 1}] is completely valid JSON.
Find the right tool, or browse Brekzy's other resources.