On this page
Overview
Ajv compiles JSON Schema or JSON Type Definition contracts into JavaScript validation functions. It runs in Node.js and browsers and supports multiple JSON Schema drafts, JTD, remote references, custom keywords, and other validation features.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Compile schemas into reusable validation functions
ajv.compile(schema) turns a schema into a validation function that returns validity and exposes validation errors. Reusing the compiled function avoids repeatedly interpreting the same schema for every input.
Choose among multiple JSON Schema drafts and JTD
Ajv supports draft-06/07/2019-09/2020-12 and JSON Type Definition. Draft-04 needs an additional package, while format validation is supplied through plugins such as ajv-formats.
Sources: [1]
Use strict mode and custom keywords to control schema behavior
Strict mode can surface ambiguous or unsupported schema constructs early, and custom keywords or asynchronous validation can extend contracts with domain-specific checks.
Sources: [1]
Best fit
Before adoption
Check schema draft and plugin requirements explicitly
Draft-04 is not handled by the Ajv v8 core alone, and formats are split into an additional plugin. Existing schemas should be reviewed for their draft version and extension keywords before migration.
Sources: [1]
Data-modifying options can mutate values during validation
Options such as removeAdditional, useDefaults, and coerceTypes can change the input data while validating it. Keep these settings separate when a boundary is expected to perform validation without transformation.
Sources: [1]
Official sources
- [1]Ajv v8.20.0 README(2026-10-05)
- [2]Ajv v8.20.0 getting started(2026-10-05)
- [3]Ajv v8.20.0 package metadata(2026-10-05)
- [4]Ajv v8.20.0 release(2026-10-05)
- [5]Ajv MIT license(2026-10-05)
Supplemental curator note
Ajv compiles schemas into JavaScript validation functions, which works well when the same contract is reused. Options such as removeAdditional, useDefaults, and coerceTypes can mutate input data, so manage them explicitly where validation is expected to be non-mutating.
Try it in 3 steps
- 1
Install Ajv 8.20.0 in an isolated project
Follow the official Getting Started flow and pin the reviewed Ajv v8 release.
demo=$(mktemp -d "${TMPDIR:-/tmp}/ajv.XXXXXX") && cd "$demo" && npm init -y >/dev/null && npm install --save-exact ajv@8.20.0 - 2
Compile a JSON Schema and check valid and invalid data
Compile a schema into a validation function and require an integer input to pass while a string input fails.
printf "%s\n" "import Ajv from 'ajv';" "const ajv = new Ajv();" "const schema = {type: 'object', properties: {foo: {type: 'integer'}}, required: ['foo'], additionalProperties: false};" "const validate = ajv.compile(schema);" "if (!validate({foo: 1})) process.exit(1);" "if (validate({foo: '1'})) process.exit(1);" "console.log(validate.errors);" > demo.mjs - 3
Run the validation with Node.js
Confirm that valid data passes and invalid data produces validation errors.
node demo.mjs
Growth
Growth trends · Last 30 days
14,850 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 0
- Open PRs
- 90
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- json-schema
- validator
- ajv
- Stars
- 14,850
- Forks
- 1,050
- Watchers
- 111
- Open issues
- 293
- Contributors
- 191
- Owner type
- Organization
- Primary language
- TypeScript
- License
- MIT
- Repository last updated
- Sep 6, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Docusaurus66,399 Stars
2 shared tag(s) · 1 shared category(s) · Same language
combine docs, blogs, custom React pages, and localization into a static documentation-site build
TypeScript - Expo52,566 Stars
2 shared tag(s) · 1 shared category(s) · Same language
build React Native apps for Android, iOS, and web from one project model
TypeScript - Typia5,931 Stars
5 shared tag(s) · 2 shared category(s) · Same language
transform TypeScript types into dedicated runtime validators and serializers at build time
TypeScript - Superstruct7,127 Stars
4 shared tag(s) · 2 shared category(s) · Same language
compose small structs to validate JavaScript and TypeScript data at runtime
TypeScript - io-ts6,814 Stars
4 shared tag(s) · 2 shared category(s) · Same language
decode and encode unknown values with codecs while inferring TypeScript types from the same definitions
TypeScript - Runtypes2,699 Stars
4 shared tag(s) · 2 shared category(s) · Same language
validate unknown values with composable runtime types and infer TypeScript types from the same definitions
TypeScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.