JSON Syntax Rules
Last updated: 26 September 2026
JSON is a deliberately small grammar: six value types, two container shapes, and a handful of characters with special meaning. Everything a parser can reject comes from one of those rules, so the whole language fits on one page.
The six value types
| Type | Example | Notes |
|---|---|---|
| String | "order-7" | Double quotes only; a few characters must be escaped |
| Number | 250, -1.5e7 | Integers and decimals; no NaN, Infinity or hex |
| Object | {"qps": 250} | Empty {} is legal; keys are quoted strings |
| Array | [1, "two", null] | Ordered, mixed types allowed, empty [] is legal |
| Boolean | true, false | Lowercase; not quoted, and not 0/1 |
| Null | null | Lowercase; means "a value that is absent", distinct from missing key |
A JSON document is exactly one value at the top level. That value may be an object, an array, a string, a number, true or null — so "hello" and 42 are both valid documents, even though most people expect the outer braces.
Objects
- Written as
{ }containing zero or more key: value pairs separated by commas. - Every key is a double-quoted string:
{"name": "Ada"}, never{name: "Ada"}or{'name': 'Ada'}. - No comma after the final pair.
{"a": 1,}is an error. - Keys are case-sensitive, and duplicate keys parse without an error but keep only one value — the winner depends on the parser, so never rely on duplicates.
- Objects are unordered collections by specification. If you need a stable order for comparison or diffs, sort the keys deliberately; the formatter does it recursively.
Arrays
- Written as
[ ]with values separated by commas, and the same no-trailing-comma rule. - Elements may mix types freely:
[1, "one", true, null, {}, []]is legal. - Arrays are ordered, which is what makes
[ ]the right shape for a list you will index into.
Strings and escapes
A string is any Unicode text between double quotes, except that two characters cannot appear literally: the double quote itself, and the backslash. Control characters below U+007F must be escaped too.
| Escape | Means |
|---|---|
\" | double quote |
\\ | backslash |
\/ | slash (optional; always safe to write) |
\b \f \n \r \t | backspace, form feed, newline, carriage return, tab |
\uXXXX | any character by four-digit hex code point; characters outside the basic plane need a surrogate pair |
Anything else after a backslash is invalid — \d, \x41 and \0 all fail. This is where Windows paths bite: "C:\new\report.json" parses as C: followed by an escape, so write "C:\\new\\report.json".
Numbers
- Optional minus, digits, optional fraction, optional exponent:
-1.5e+7is fine. - No leading zeros (
01is invalid;0and0.1are fine), no trailing decimal point, no+sign, no hexadecimal, no octal, no digit separators. - Numbers must not be quoted if you want arithmetic:
"250"is a string as far as any parser is concerned, and that single mistake causes a large share of integration bugs. - The grammar itself puts no bound on magnitude, but most parsers read numbers as IEEE-754 doubles, so integers above 253 lose precision — snowflake IDs and Twitter IDs should travel as strings.
What JSON does not have
Knowing the absences settles most arguments with an editor that seems more permissive than the parser:
- Comments — no
//, no/* */. Files that need them are JSONC, common in TypeScript configs, and must be stripped before parsing. - undefined — omit the key instead, or use
null. - Dates, binary, functions, sets, maps — encode as a string, or a base64 string, and decide the convention with whoever reads it.
- Single quotes, multiline raw strings, trailing commas — all invalid, all commonly produced by copy-pasting from JavaScript.
- Multiple values per document — one JSON value only. Newline-delimited records are NDJSON, a different format with its own parser.
The eight mistakes that cause almost every parse error
{"a": 1,}— trailing comma. Fix: remove it.{'a': 1}— single quotes. Fix: use double quotes on both key and value.{a: 1}— unquoted key. Fix:{"a": 1}.// configat the top — a comment. Fix: delete it, or parse as JSONC with a tool that supports it.{"ok": True}— capitalised literal. Fix:true.{"v": NaN}— non-finite number. Fix:nullor a string.{"p": "C:\new"}— bad escape. Fix: double the backslash.{“a”: 1}— smart quotes pasted from a document or slide. Fix: retype them as straight quotes.
Each of these is reported with its exact line and column by the JSON validator, along with the cause in words.
Frequently Asked Questions
What are the six JSON value types?
String, number, object, array, true and false, and null. Those are the only kinds of value JSON can represent — there is no date, binary, undefined or comment type.
Are trailing commas allowed in JSON?
No. A comma must sit between two values, so the last item in an object or array is never followed by one. JavaScript object literals and JSON5 allow trailing commas, which is why files that look fine in an editor still fail to parse.
Do JSON keys have to be in double quotes?
Yes. Every property name must be a double-quoted string. Unquoted keys, single quotes and backticks are all invalid, and keys are case-sensitive: name and Name are two different properties.
Can JSON store dates?
Not as a distinct type. Dates are conventionally written as ISO 8601 strings such as 2026-09-26T09:00:00Z, or as a Unix timestamp number, and converted back to a date object in the code that reads them.
Is JSON case-sensitive?
Yes, for keys and for string values. The literals are also case-sensitive: true, false and null must be lowercase, and True or NULL will not parse.
Something missing or wrong on this page? Tell us — this cheat sheet follows RFC 8259, and corrections that quote the grammar are the most useful kind.