OSS TanbouSign in with GitHub

compile JSON Schema or JTD contracts into fast runtime validators for API and configuration data

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
14,850
Primary language
TypeScript
License
MIT
Repository last updated
Sep 6, 2026
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.

Sources: [2][1]

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

Fits runtime validation of API requests, configuration, and event payloads

It is useful when JSON Schema is a shared contract and APIs, frontends, backends, gateways, or configuration loaders need to validate external objects at runtime.

Sources: [1][2]

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. [1]Ajv v8.20.0 README(2026-10-05)
  2. [2]Ajv v8.20.0 getting started(2026-10-05)
  3. [3]Ajv v8.20.0 package metadata(2026-10-05)
  4. [4]Ajv v8.20.0 release(2026-10-05)
  5. [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. 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. 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. 3

    Run the validation with Node.js

    Confirm that valid data passes and invalid data produces validation errors.

    node demo.mjs
Check the official README

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

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
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?