JSON Syntax

Learn the rules and structure of JSON: objects, arrays, data types, and formatting. This page covers everything you need to know to write valid JSON.

Basic Structure

JSON is built on two structures:

  1. Objects: Unordered collections of key-value pairs
  2. Arrays: Ordered sequences of values

Data Types

Strings

Double-quoted text:

"Hello, World!"

Numbers

Integer or floating-point:

42
3.14

Booleans

true or false:

true
false

Null

Represents empty value:

null

Objects

{
  "name": "John",
  "age": 30,
  "isActive": true
}

Arrays

["apple", "banana", "orange"]

Nested Structures

{
  "person": {
    "name": "John",
    "hobbies": ["reading", "gaming"]
  }
}

Rules

  1. Use double quotes for strings
  2. No trailing commas
  3. No comments
  4. No functions or expressions
  5. Keys must be strings