Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

ajv

> 编程语言
Open source

The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)

14.8K stars0 likes3 views
WebsiteGitHub

About

The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)

 

Ajv JSON schema validator

The fastest JSON validator for Node.js and browser.

Supports JSON Schema draft-04/06/07/2019-09/2020-12 (draft-04 support requires ajv-draft-04 package) and JSON Type Definition RFC8927.

Ajv sponsors

Contributing

More than 100 people contributed to Ajv, and we would love to have you join the development. We welcome implementing new features that will benefit many users and ideas to improve our documentation.

Please review Contributing guidelines and Code components.

Documentation

All documentation is available on the Ajv website.

Some useful site links:

  • Getting started
  • JSON Schema vs JSON Type Definition
  • API reference
  • Strict mode
  • Standalone validation code
  • Security considerations
  • Command line interface
  • Frequently Asked Questions

Please sponsor Ajv development

Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant!

Your continuing support is very important - the funds will be used to develop and maintain Ajv once the next major version is released.

Please sponsor Ajv via:

  • GitHub sponsors page (GitHub will match it)
  • Ajv Open Collective

Thank you.

Open Collective sponsors

Performance

Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.

Currently Ajv is the fastest and the most standard compliant validator according to these benchmarks:

  • json-schema-benchmark - 50% faster than the second place
  • jsck benchmark - 20-190% faster
  • z-schema benchmark
  • themis benchmark

Performance of different validators by json-schema-benchmark:

Features

  • Ajv implements JSON Schema draft-06/07/2019-09/2020-12 standards (draft-04 is supported in v6):
    • all validation keywords (see JSON Schema validation keywords)
    • OpenAPI extensions:
      • NEW: keyword discriminator.
      • keyword nullable.
    • full support of remote references (remote schemas have to be added with addSchema or compiled to be available)
    • support of recursive references between schemas
    • correct string lengths for strings with unicode pairs
    • JSON Schema formats (with ajv-formats plugin).
    • validates schemas against meta-schema
  • NEW: supports JSON Type Definition:
    • all keywords (see JSON Type Definition schema forms)
    • meta-schema for JTD schemas
    • "union" keyword and user-defined keywords (can be used inside "metadata" member of the schema)
  • supports browsers and Node.js 18.x - current
  • asynchronous loading of referenced schemas during compilation
  • "All errors" validation mode with option allErrors
  • error messages with parameters describing error reasons to allow error message generation
  • i18n error messages support with ajv-i18n package
  • removing-additional-properties
  • assigning defaults to missing properties and items
  • coercing data to the types specified in type keywords
  • user-defined keywords
  • additional extension keywords with ajv-keywords package
  • $data reference to use values from the validated data as values for the schema keywords
  • asynchronous validation of user-defined formats and keywords

Install

To install version 8:

bash
npm install ajv

Getting started

Try it in the Node.js REPL: https://runkit.com/npm/ajv

In JavaScript:

javascript
// or ESM/TypeScript import
import Ajv from "ajv"
// Node.js require:
const Ajv = require("ajv")

const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}

const schema = {
  type: "object",
  properties: {
    foo: {type: "integer"},
    bar: {type: "string"},
  },
  required: ["foo"],
  additionalProperties: false,
}

const data = {
  foo: 1,
  bar: "abc",
}

const validate = ajv.compile(schema)
const valid = validate(data)
if (!valid) console.log(validate.errors)

Learn how to use Ajv and see more examples in the Guide: getting started

Changes history

See https://github.com/ajv-validator/ajv/releases

Please note: Changes in version 8.0.0

Version 7.0.0

Version 6.0.0.

Code of conduct

Please review and follow the Code of conduct.

Please report any unacceptable behaviour to [email protected] - it will be reviewed by the project team.

Security contact

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues.

Open-source software support

Ajv is a part of Tidelift subscription - it provides a centralised support to open-source software users, in addition to the support provided by software maintainers.

License

MIT

Issues· 380 open

View all issuesOpen on GitHub
  • #2674

    feat: support trusted types for jit compilation

    enhancementUpdated Sep 24, 2026
  • #2673

    coerceTypes option interfere in the validation with the not keyword

    bug reportUpdated Sep 24, 2026
  • #1793

    consider removing require-from-string dependency

    enhancementUpdated Sep 23, 2026
  • #1978

    CVE-2021-44906 vulnerability in uri-js dependency

    installationUpdated Sep 21, 2026
  • #2545

    Error message from strict schema validation does not contain whole path

    bug reportUpdated Sep 14, 2026
  • #2670

    Suggestion: optional comment-only second opinion on Dependabot PRs

    Updated Sep 7, 2026
  • #2660

    Track fast-uri v4 migration (currently pinned to ^3.0.1)

    Updated Aug 31, 2026
  • #2658

    CVE-2026-16221 vulnerability in fast-uri

    bug reportUpdated Aug 24, 2026
  • #2666

    Using $schema to validate against meta-schema is protocol-sensitive. Should it?

    enhancementUpdated Aug 15, 2026
  • #2664

    required/properties/dependencies treat Object.prototype property names (toString, constructor, __proto__) as present in the data

    Updated Aug 13, 2026

> Tags

TypeScriptajvjson-schemavalidator

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言