What is JSON Schema?¶
JSON Schema is a declarative language that you can use to annotate and validate the structure, constraints, and data types of your JSON documents. It provides a way to standardize and define expectations for your JSON data.
Overview¶
This documentation describes JSON Schema and the many ways you can use it to ensure the consistency of your JSON data. Here’s what you’ll find in the documentation:
- Getting Started: If you’re new to JSON Schema, start here. You’ll find a step-by-step guide that walks you through creating your first JSON Schema, along with some real-world examples.
- Reference: This section provides a glossary, specification release notes, and in-depth reference to JSON Schema that you can use to write and understand more complex schemas.
Why JSON Schema?¶
JSON Schema can:
- Describe your existing data formats
- Provide clear documentation that’s both human and machine readable
- Validate your data, which helps you:
- Automate testing
- Ensure the quality of client-submitted data
JSON Schema is highly extensible and can be tailored to fit your needs. You can create custom keywords, formats, and validation rules to suit your own requirements. The JSON Schema community has a wealth of tools and resources available across many programming languages to help you create, validate, and integrate your schemas.
How it works¶
Using JSON Schema, you can define rules and constraints that JSON data should adhere to. When your JSON documents adhere to these constraints, it becomes easier to exchange structured data between applications because the data follows a consistent pattern.
You begin by defining the rules in a JSON Schema document using various keywords. For example, you can use type
to specify what types of data are valid for a given key. You can specify either a single type, like string
, or an array of possible types, like string
, number
, or integer
. You can also enforce formats using regular expressions with the pattern
keyword. There are countless ways to describe specific data types and formats that your data must follow.
After you define your schema, you validate your JSON documents against the schema. To do this, you can use any supported validator in whatever language or context fits your project. There are JSON Schema validation tools for nearly every modern programming language, as well as language-agnostic command-line and browser tools.
When you have a defined schema and valid JSON data, the possibilities are endless. You can do additional data processing, set up error handling, and integrate your validated data with APIs, other applications, and business logic.
Next steps¶
To start using JSON Schema, see Creating your first schema.
Learn more¶
Learn more about the specification:
Join the community¶
To get involved with our community, please make sure you are familiar with the project's Code of Conduct.
- Join JSON Schema Slack. This is the best place to ask questions, learn, get help, or discuss all things JSON Schema.
- Attend our public JSON Schema meetings. We hold Office Hours every first Tuesday at 15:00 BST (and by appointment) and Open Community Working Meetings every Monday at 14:00 PT.
- Follow our YouTube channel. Find recordings of our public community meetings and JSON Schema learning resources.
- Read our blog. Find the latest and greatest stories from our community.