minItems
Specifies the minimum number of items in an array.Syntax
The value must be a non-negative integer.Validation Rules
An array instance is valid if its size (number of elements) is greater than or equal to the specified value.Default Behavior
OmittingminItems is equivalent to minItems: 0, which allows empty arrays.
Examples
Non-Empty Array
At Least Two Items
maxItems
Specifies the maximum number of items in an array.Syntax
The value must be a non-negative integer.Validation Rules
An array instance is valid if its size (number of elements) is less than or equal to the specified value.Examples
Limited Array Size
Single Item Array
uniqueItems
Requires that all items in an array be unique.Syntax
The value must be a boolean.Validation Rules
- If
uniqueItemsisfalse, the instance validates successfully (duplicates allowed) - If
uniqueItemsistrue, the instance validates successfully only if all elements are unique
Default Behavior
OmittinguniqueItems is equivalent to uniqueItems: false, which allows duplicates.
Equality
Elements are considered equal according to the equality rules defined in the JSON Schema Core specification.Examples
Unique Numbers
Unique Objects
Mixed Type Array
Combining Array Keywords
Multiple array validation keywords can be used together to define precise constraints.Size Range
Unique Tags
Coordinates (Pair)
Team Members
Fixed Size Array
Optional Array
Use Cases
- minItems: Ensure at least one selection (e.g., order items, selected options)
- maxItems: Limit number of tags, attachments, or choices
- uniqueItems: Prevent duplicate selections, tags, or IDs
- Combined: Define precise constraints like “select 3-5 unique categories”