Skip to main content
The properties keyword defines schemas that validate specific properties of a JSON object. Each property name maps to a schema that validates the corresponding property value.

Syntax

The value must be an object where each value is a valid JSON Schema.

Behavior

Validation succeeds if, for each property name that appears in both the instance and this keyword’s value, the instance property value validates against the corresponding schema.
  • Only properties present in both the instance and properties are validated
  • Additional properties in the instance are ignored by this keyword
  • Missing properties specified in properties are allowed (use required to mandate them)
  • Produces an annotation containing the set of property names validated
  • Affects behavior of additionalProperties and unevaluatedProperties

Examples

Basic Object Schema

Define expected object properties:
Valid:
Invalid:

Nested Objects

Define schemas for nested object properties:
Valid:

With Required Properties

Combine with required to mandate specific properties:
Valid:
Invalid:

Complex Property Schemas

Use advanced schemas for property validation:
Valid:

API Response Schema

Define structure for API responses:

Configuration Object

Validate application configuration:

Using References

Reuse property schemas with $ref:

Interaction with Other Keywords

With additionalProperties

properties determines which properties are considered “known”:
Valid: { "name": "Alice" }
Invalid: { "name": "Alice", "age": 30 } (age is additional)

With patternProperties

Both can apply to the same property:
The name property must satisfy both schemas.

With unevaluatedProperties

Properties validated by properties are marked as evaluated:
Valid: { "id": 1 }
Invalid: { "id": 1, "name": "test" }

Annotations

The properties keyword produces an annotation containing the set of instance property names that were validated. This annotation is used by:
  • additionalProperties to determine which properties are “additional”
  • unevaluatedProperties to determine which properties are “unevaluated”

Common Use Cases

  • Object validation: Define structure and constraints for JSON objects
  • API schemas: Validate request/response payloads
  • Configuration files: Ensure config objects have correct structure
  • Data models: Define entity schemas for data validation
  • Form validation: Validate user input objects

Notes

  • Omitting properties is equivalent to an empty object (no validation)
  • Properties not listed in properties are not validated by this keyword
  • Use required separately to mandate property presence
  • Combines naturally with additionalProperties to control object shape
  • The annotation is essential for the proper functioning of additionalProperties and unevaluatedProperties

Best Practices

  • Always specify type: "object" when using properties
  • Use required to explicitly list mandatory properties
  • Combine with additionalProperties: false for strict object shapes
  • Use $ref to reuse common property schemas
  • Provide clear descriptions for each property to aid documentation