What Is a JSON Object

A JSON object is a collection of key-value pairs, delimited by curly braces {}. It’s the most fundamental structure in JSON, used to represent an entity with named properties, like a person, a product, or a configuration.

Basic syntax

// json
{
  "name": "Ana",
  "age": 30,
  "active": true
}

Each pair consists of a key (always a string, in double quotes) and a value, separated by a colon. Different pairs are separated by commas.

Important rules

  • Keys always in double quotes, never single or unquoted
  • No comma allowed after the last pair (trailing comma)
  • Duplicate keys are technically allowed by the syntax, but the behavior is undefined, most parsers just use the last value

Objects can be empty

// json
{}

An empty object is perfectly valid JSON.

Objects can contain other objects (nesting)

// json
{
  "name": "Ana",
  "address": {
    "city": "New York",
    "zip": "10001"
  }
}

Object vs array: the key difference

An object uses named keys to access values (data.name), while an array uses numeric position (data[0]). If the order of items doesn’t matter and each one has a “name” that makes sense, it’s usually an object. If order matters and the items are all the same type/category, it’s usually an array.

If you’re unsure about the difference between an object and an array, JSON Validator helps visualize the structure of any JSON clearly.