Guide · Updated 2026-07-29

JSON Syntax and Structure

Every valid JSON document is built from just six data types and a small set of structural rules. Here's exactly what they are, with examples of what's valid and what isn't.

The six JSON data types

Object — an unordered set of key-value pairs in curly braces: {"key": "value"}. Array — an ordered list of values in square brackets: [1, 2, 3]. String — text in double quotes: "hello". Number — an integer or decimal, no quotes: 42 or 3.14. Boolean — exactly true or false, unquoted. Null — the literal null, representing "no value."

Object structure rules

Keys must always be double-quoted strings — never single-quoted, never unquoted. Each key-value pair is separated by a colon, and pairs are separated by commas, with no comma after the last pair: {"a": 1, "b": 2} is valid; {"a": 1, "b": 2,} is not.

Array structure rules

Arrays hold an ordered sequence of any JSON values — including mixed types or nested objects/arrays — separated by commas, again with no trailing comma: [1, "two", true, null, {"nested": true}].

String rules

Strings must use double quotes, not single quotes. Special characters need escaping with a backslash: \" for a quote, \\ for a backslash, \n for a newline, and \uXXXX for arbitrary Unicode characters. Our JSON Escape tool handles this automatically.

What makes JSON invalid

The most common mistakes: trailing commas after the last item, single quotes instead of double quotes, unquoted object keys, and using undefined (which doesn't exist in JSON — use null instead). Any of these will cause a strict parser to reject the document; run it through our JSON Validator to find the exact line and column.

Frequently asked questions

What are the basic data types in JSON?

JSON supports six types: object, array, string, number, boolean (true/false), and null. Every value in a JSON document is one of these.

What is a JSON object?

A JSON object is an unordered set of key-value pairs enclosed in curly braces, where each key is a double-quoted string, e.g. {"name": "Ada", "age": 36}.

Can JSON have comments?

No. Strict JSON does not support comments of any kind. Some parsers accept a relaxed superset like JSON5 or JSONC that does, but standard JSON does not.

Are trailing commas allowed in JSON?

No. A comma after the last item in an object or array makes the JSON invalid, even though this is legal in JavaScript object literals.