Overview

Use Cases

Discover everything you can do with JSON Schema. This section presents the most common use cases for JSON Schema, but but there may be many more applications waiting to be discovered.

Structural validation

Structural validation


Structural validation refers to the structure that a JSON document is supposed to follow, such as which properties must exist, what types of values are expected where, and what they must look like.

Semantic annotation

Semantic annotation


There is a need to annotate values within a JSON document: for machine readability, and for documentation purposes.

Domain-specific language

Domain-specific language


Developers may write an application that uses a JSON Schema internally as a domain-specific language, so that the schema is only used inside a single application by a single party. By using a declarative language, the application requirements can be optimized better than a human could do.

A common vocabulary

A common vocabulary


A development team maintains two similar applications, but for different platforms, in different languages. The application downloads and reads from a common repository of JSON documents. They want to make sure that both applications accept or reject JSON with identical behavior, so they write a single JSON Schema and deploy it to both applications.

Model-Driven UI constraints

Model-Driven UI constraints


When a server declares constraints that a submission must meet, there is a need for the user interface to receive these constraints to provide model-driven validation of permissible values, making the form more accessible to the user.

UI Generation

UI Generation


JSON Schema can be used to automatically generate user interfaces that adhere to a given schema.

Data Serialization

Data Serialization


Compress JSON data for storage/transmission. For example: https://jsonbinpack.sourcemeta.com

Fuzzing, enumeration, and generation

Fuzzing, enumeration, and generation


Security applications need to generate examples of JSON documents within the valid set, and outside the valid set.

Partial validation

Partial validation


Due to technical limitations, some JSON parsers may only be able to understand a subset of the JSON value space, and it makes sense to validate the value read by the application, instead of the JSON document provided to the JSON parser.

Automated Testing

Automated Testing


Good definitions of input/output that schemas provide enable contract and property based testing scenarios. For example: https://schemathesis.readthedocs.io/en/stable/

Machine-readable profiles of Web resources

Machine-readable profiles of Web resources


A Web server that offers a JSON document should be able to link to a profile document that describes the meaning of the data in a machine-readable form.

Schema Inference

Schema Inference


This is pretty useful in data science. You may have huge JSON datasets and don't know the structure well. You can use tools that will derive a JSON Schema from the data for you to better understand it and act on it.

Hypermedia

Hypermedia


Generic user-agents must be able to make use of the schema as it evolves, including Web browsers, spiders, and automated tooling. It should support loose coupling (like an HTML homepage); so a schema should be able to change, add, and remove features with minimal breakage for compatible clients.

Results and Reporting

Results and Reporting


The party that is providing the schema and input may not be the same party that is performing the validation; in this case, there should be a standard way to abstract away the validator interface, and report the results of a validation operation (validation result, annotations, and errors).

External validation

External validation


Authors may embed resources of other media types, such as text documents, or base64 or hex-encoded binary documents; and may wish to pass off validation of these documents to another software tool.

Intra-document data consistency validation

Intra-document data consistency validation


A JSON document may carry relational data that must be internally consistent.

Inter-database consistency validation

Inter-database consistency validation


A JSON document may carry relational data that must be verified against outside data sources.

Linting

Linting


Sometimes it's desirable to require formatting that does not impact the application-level meaning of the document, but instead specifies requirements purely for aesthetic or compatibility reasons.

Need Help?

Did you find these docs helpful?

Help us make our docs great!

At JSON Schema, we value docs contributions as much as every other type of contribution!

Still Need Help?

Learning JSON Schema is often confusing, but don't worry, we are here to help!.