JSON Schema Array of Objects: items, required, and examples

To validate an array of objects in JSON Schema, set the top-level schema to {"type":"array"} and define each element with items. Put properties, required, and additionalPropertiesinside the items object schema.

Testing a schema against real data? Paste both into Jsonic's JSON Schema Validator and see item-level errors instantly.

Validate JSON Schema

Basic array of objects schema

This schema validates an array where every item is an object with an id, name, and optional email.

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "integer" },
      "name": { "type": "string" },
      "email": { "type": "string", "format": "email" }
    },
    "required": ["id", "name"]
  }
}

Valid data:

[
  { "id": 1, "name": "Alice", "email": "alice@example.com" },
  { "id": 2, "name": "Bob" }
]

Required fields inside array items

The required keyword applies to the object schema that contains it. For an array of objects, put required inside items, not next to the array's top-level type.

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "sku": { "type": "string" },
      "quantity": { "type": "integer", "minimum": 1 }
    },
    "required": ["sku", "quantity"]
  }
}

For more required-field examples, see the JSON Schema examples guide.

minItems, maxItems, and uniqueItems

Array-level constraints belong beside items. Use them to control how many objects the array may contain.

{
  "type": "array",
  "minItems": 1,
  "maxItems": 100,
  "uniqueItems": true,
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "integer" }
    },
    "required": ["id"]
  }
}

uniqueItems compares whole array items. It does not mean "unique by id"; two objects with different names but the same id are still different objects unless every property matches.

Reject extra fields with additionalProperties

Set additionalProperties: false inside the item object schema to reject unknown fields on every object in the array.

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "integer" },
      "name": { "type": "string" }
    },
    "required": ["id", "name"],
    "additionalProperties": false
  }
}

Without this setting, JSON Schema allows extra properties by default. That is useful for flexible API clients, but strict config files usually set it to false.

Nested arrays inside objects

An object inside the array can contain its own arrays. Define those nested arrays under the item's properties.

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "orderId": { "type": "string" },
      "lines": {
        "type": "array",
        "minItems": 1,
        "items": {
          "type": "object",
          "properties": {
            "sku": { "type": "string" },
            "qty": { "type": "integer", "minimum": 1 }
          },
          "required": ["sku", "qty"]
        }
      }
    },
    "required": ["orderId", "lines"]
  }
}

Tuple validation

A normal items object means every array element follows the same schema. Tuple validation is different: each array position has its own schema.

{
  "type": "array",
  "items": [
    { "type": "string" },
    { "type": "integer" },
    { "type": "boolean" }
  ],
  "additionalItems": false
}

Use tuple validation for fixed-position records like ["Alice", 42, true]. Use items for lists where every object has the same shape.

Common errors

ErrorFix
required placed beside itemsMove it inside the item object schema
Using properties directly on an arrayPut properties inside items
Expecting uniqueItems to mean unique IDsEnforce ID uniqueness in application logic
Extra item fields are acceptedAdd additionalProperties: false inside items

The JSON Schema examples guide has more copy-paste snippets for objects, enums, strings, numbers, and composition.

Frequently asked questions

How do I define an array of objects in JSON Schema?

Use type: "array" and put an object schema inside items. The object schema contains properties, required, and any object constraints such as additionalProperties.

Where do required fields go?

Put required inside the items object schema. If you put it on the top-level array schema, it will not require fields on each object.

Can JSON Schema validate every item in an array?

Yes. When items is a schema object, JSON Schema applies that schema to every element in the array.

Validate your array schema

Paste your schema and sample JSON into Jsonic's JSON Schema Validator to check item paths, required fields, and nested array rules.

Open Schema Validator