JSON Schema is a vocabulary that allows you to annotate and validate JSON documents.
- describes your existing data format
- clear, human- and machine-readable documentation
- complete structural validation, useful for
- automated testing
- validating client-submitted data
- describes your existing API - no new structures required
- links (including URI Templates for target URIs)
- forms - specify a JSON Schema for the desired data
The JSON document being validated or described we call the instance, and the document containing the description is called the schema.
The most basic schema is a blank JSON object, which constrains nothing, allows anything, and describes nothing:
You can apply constraints on an instance by adding validation keywords to the schema. For instance, the "type" keyword can be used to restrict an instance to an object, array, string, number, boolean, or null:
JSON Schema is hypermedia ready, and ideal for annotating your existing JSON-based HTTP API. JSON Schema documents are identified by URIs, which can be used in HTTP Link headers, and inside JSON Schema documents to allow recursive definitions.
Interested? Check out:
- the specification
- some examples
- this excellent guide for schema authors, from the Space Telescope Science Institute
- the growing list of JSON (Hyper-)Schema software
Questions? Feeling helpful? Get involved on: