explaingit

ajv-validator/ajv

Analysis updated 2026-06-24

14,705TypeScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

Fast JSON Schema validator for Node and browsers, supporting drafts 04 through 2020-12 and JSON Type Definition. Used as plumbing inside other tools to check API payloads and config files.

Mindmap

mindmap
  root((ajv))
    Inputs
      JSON Schema
      JSON Type Definition
      Runtime data
    Outputs
      Validation result
      Error list
      Standalone code
    Use Cases
      API payload checks
      Config file checks
      Form data checks
      Build time validation
    Tech Stack
      TypeScript
      Node.js
      Browser
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Validate incoming JSON request bodies in an Express or Fastify API

USE CASE 2

Generate standalone validator code at build time to skip runtime schema compile

USE CASE 3

Enforce config file shape on app startup with a clear error report

USE CASE 4

Validate form data in the browser before sending to a server

What is it built with?

TypeScriptNode.jsJSON Schema

How does it compare?

ajv-validator/ajvformatjs/formatjsjcodesmore/ai-website-cloner-template
Stars14,70514,70814,708
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderatemoderate
Complexity2/53/53/5
Audiencedeveloperdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Draft-04 schemas need the extra ajv-draft-04 package, and strict mode rejects some loose schemas that work elsewhere.

In plain English

Ajv is a JSON validator for Node.js and the browser. Its job is simple to describe: you hand it a schema (a set of rules about what a JSON document should look like) and some data, and Ajv tells you whether the data matches the rules. The README calls it the fastest JSON validator and notes that more than 100 people have contributed to it over the years. A schema is just a description of the expected shape of data, such as which fields are required, what types they should be, and what values are allowed. Ajv supports several versions of the JSON Schema standard, specifically drafts 04, 06, 07, 2019-09, and 2020-12. Support for the older draft-04 needs an extra package called ajv-draft-04. It also supports JSON Type Definition, a newer alternative format defined in RFC 8927. The project's website explains the difference between the two languages so users can pick the right one for their case. The README itself is mostly a landing page. It points to the documentation site at ajv.js.org, which holds a getting started guide, an API reference, notes on strict mode, instructions for generating standalone validation code, security considerations, a command line interface called ajv-cli, and a frequently asked questions page. Most users will spend their time on the documentation site rather than in this repository. The project is sponsored by organisations including Mozilla, Microsoft, Retool, Tidelift, and SimpleX, and it has received a MOSS grant. The author asks for sponsorship through GitHub Sponsors or Open Collective to keep development going, especially around the next major version. There is also a contributing guide for people who want to help with code or documentation. For a non-technical reader, the main thing to take away is that Ajv is plumbing. Other tools and libraries use it under the hood to check that JSON data, often from APIs or configuration files, follows agreed-on rules before they try to use it.

Copy-paste prompts

Prompt 1
Set up Ajv in a TypeScript Node project and validate one POST body against a schema
Prompt 2
Show how to use Ajv standalone mode to precompile validators into a file at build time
Prompt 3
Compare JSON Schema and JSON Type Definition modes in Ajv for the same data shape
Prompt 4
Add Ajv to a Fastify route so invalid requests return a 400 with the error list
Prompt 5
Convert an existing Joi schema to a JSON Schema that Ajv 2020-12 can validate

Frequently asked questions

What is ajv?

Fast JSON Schema validator for Node and browsers, supporting drafts 04 through 2020-12 and JSON Type Definition. Used as plumbing inside other tools to check API payloads and config files.

What language is ajv written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js, JSON Schema.

How hard is ajv to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is ajv for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.