Skip to content

Basics for Beginners · JSON Syntax Rules — The Golden Rules

All tutorials

JSON Syntax Rules — The Golden Rules

Follow these rules or your JSON will be invalid.

  • Keys must be strings in double quotes — not single quotes
  • Strings must use double quotes — single quotes are invalid
  • No trailing commas after the last item in objects or arrays
  • No comments allowed — JSON has no // or /* */ support
  • true, false, and null must be lowercase
  • Numbers have no quotes: use 42, not "42"
  • Commas separate items; no comma after the last item
// ✅ Valid JSON
{"name": "Alice", "age": 30}

// ❌ Invalid: single quotes
{'name': 'Alice'}

// ❌ Invalid: trailing comma
{"name": "Alice",}

// ❌ Invalid: unquoted key
{name: "Alice"}