Skip to content
Free Tool Arena

Glossary · Definition

JSON syntax rules

JSON syntax: 6 value types (string, number, true, false, null, object, array). Strings use double quotes ONLY. Object keys must be quoted strings. No trailing commas, no comments, no single quotes. Common errors: missing commas, unquoted keys, trailing commas after last item.

Updated May 2026 · 4 min read
100% in-browserNo downloadsNo sign-upMalware-freeHow we keep this safe →

Definition

JSON syntax: 6 value types (string, number, true, false, null, object, array). Strings use double quotes ONLY. Object keys must be quoted strings. No trailing commas, no comments, no single quotes. Common errors: missing commas, unquoted keys, trailing commas after last item.

What it means

RFC 8259 specifies six allowed value types and their syntax. <strong>Strings</strong>: double-quoted only (no single quotes), with backslash escapes for special chars (<code>\&quot;</code>, <code>\\</code>, <code>\n</code>, <code>\t</code>, <code>\u0041</code>). <strong>Numbers</strong>: integers and floats (no leading zeros, no octal/hex, no NaN, no Infinity). <strong>Boolean</strong>: only <code>true</code> and <code>false</code> (lowercase). <strong>Null</strong>: <code>null</code> (lowercase). <strong>Objects</strong>: <code>&#123;key: value, ...&#125;</code> with quoted string keys, comma-separated, no trailing comma. <strong>Arrays</strong>: <code>[value, value, ...]</code> with elements comma-separated, no trailing comma. <strong>Nesting</strong>: arbitrary depth (some parsers limit to 100-1000 levels).

Advertisement

Why it matters

Most JSON parse errors come from these specific rules. Knowing them speeds debugging dramatically. JavaScript developers especially trip over JSON&rsquo;s strictness — JS allows trailing commas, single quotes, unquoted keys; JSON doesn&rsquo;t. Copy-paste from JavaScript object literals into a JSON file usually breaks. Common error message: <code>SyntaxError: Unexpected token X at position N</code> — N is the character position; look for the most common errors first.

Example

VALID: <code>&#123;&quot;name&quot;: &quot;ada&quot;, &quot;skills&quot;: [&quot;js&quot;, &quot;python&quot;]&#125;</code>. INVALID: <code>&#123;name: &lsquo;ada&rsquo;, &quot;skills&quot;: [&quot;js&quot;, &quot;python&quot;,]&#125;</code> (unquoted key, single quotes, trailing comma).

Related free tools

Frequently asked questions

Can JSON have comments?

No — strict JSON forbids comments. Use JSON5 or JSONC if you need them. For pure JSON config files, document via README or external schema instead.

What&rsquo;s the maximum nesting depth?

RFC doesn&rsquo;t specify; parsers vary. JavaScript JSON.parse handles 1000-2000 levels; some embedded parsers cap at 100. Avoid deeply nested JSON in production — flatten or use references.

Why are trailing commas not allowed?

Historical: JSON was designed in 2001 when many parsers didn&rsquo;t handle them. Modern parsers can handle them but the standard remained strict. JSON5 / JSONC removed this restriction.

Related terms