← Back to the JSON tool

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

TypeExampleNotes
String"order-7"Double quotes only; a few characters must be escaped
Number250, -1.5e7Integers 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
Booleantrue, falseLowercase; not quoted, and not 0/1
NullnullLowercase; 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

Arrays

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.

EscapeMeans
\"double quote
\\backslash
\/slash (optional; always safe to write)
\b \f \n \r \tbackspace, form feed, newline, carriage return, tab
\uXXXXany 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

What JSON does not have

Knowing the absences settles most arguments with an editor that seems more permissive than the parser:

The eight mistakes that cause almost every parse error

  1. {"a": 1,} — trailing comma. Fix: remove it.
  2. {'a': 1} — single quotes. Fix: use double quotes on both key and value.
  3. {a: 1} — unquoted key. Fix: {"a": 1}.
  4. // config at the top — a comment. Fix: delete it, or parse as JSONC with a tool that supports it.
  5. {"ok": True} — capitalised literal. Fix: true.
  6. {"v": NaN} — non-finite number. Fix: null or a string.
  7. {"p": "C:\new"} — bad escape. Fix: double the backslash.
  8. {“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.