docs/README.md
Ensure your data is valid once it is received
</Feature> <Feature type="fast-secure" link="/guide/why-ajv.html#super-fast-secure">Compiles your schemas to optimized JavaScript code
</Feature> <Feature type="multi-spec" link="/guide/why-ajv.html#multi-standard">Use JSON Type Definition or JSON Schema
</Feature> </Features> <Sponsors level="platinum">Ajv is used by a large number of JavaScript applications and libraries in all JavaScript environments - Node.js, browser, Electron apps, WeChat mini-apps etc.
It allows implementing complex data validation logic via declarative schemas for your JSON data, without writing code.
Out of the box, Ajv supports JSON Schema (drafts 04, 06, 07, 2019-09 and 2020-12) and JSON Type Definition (RFC8927).
<Button link="/guide/getting-started.html">Learn Ajv</Button>
</Column> <Column side="right"> <code-group> <code-block title="JSON Schema"> ```javascript const Ajv = require("ajv") const ajv = new Ajv()const schema = { type: "object", properties: { foo: {type: "integer"}, bar: {type: "string"} }, required: ["foo"], additionalProperties: false }
const data = {foo: 1, bar: "abc"} const valid = ajv.validate(schema, data) if (!valid) console.log(ajv.errors)
</code-block>
<code-block title="JSON Type Definition">
```javascript
const Ajv = require("ajv/dist/jtd")
const ajv = new Ajv()
const schema = {
properties: {
foo: {type: "int32"}
},
optionalProperties: {
bar: {type: "string"}
}
}
const data = {foo: 1, bar: "abc"}
const valid = ajv.validate(schema, data)
if (!valid) console.log(ajv.errors)
Ajv stands out as the implementation of choice - it provides a rich API which many thousands of people use in production... Ajv is partly responsible for the success of JSON Schema.
Ben Hutton, JSON Schema Specification Lead
</Testimonial> <Testimonial color="blue">ESLint has used Ajv for validating our complex configurations. Ajv has proven to be reliable over the years we’ve been using it and ESLint is proud to sponsor Ajv’s continued development.
Nicholas C. Zakas, ESLint creator and TSC member
</Testimonial> </Testimonials><span style="float:right;">All quotes</span>
</HomeSection> <HomeSection>Ajv is free to use and open-source that many developers contributed to. Join us!
<Contributors /> </HomeSection> <HomeSection section="footer"> <FooterColumns> <FooterColumn type="ajv">  </FooterColumn> <FooterColumn type="links"> </FooterColumn> <FooterColumn type="links"> </FooterColumn> <FooterColumn type="sponsors"> </FooterColumn> </FooterColumns>© 2015-2021 | Ajv JSON schema validator | [email protected]
</HomeSection>