# Ajv JSON Validator

Safety, security and reliability for JavaScript applications

Write less code

Ensure your data is valid once it's received

Super fast and secure

The fastest and the most secure JSON validator

Multi-specification

Choose your JSON schema standard


# Ajv News

This section will include the last update and the headlines of several previous updates, e.g. these sections:

https://github.com/ajv-validator/ajv#using-version-7

https://github.com/ajv-validator/ajv#mozilla-moss-grant-and-openjs-foundation

# Write less code

Ensure your data is valid once it's received

Instead of having your data validation and sanitization logic scattered around your code, you can express the requirements to your data with concise, easy to read and cross-platform JSON Schema (opens new window) or JSON Type Definition (opens new window) specifications and validate the data as soon as it arrives to your application. TypeScript users can use validation functions as type guards, having type level guarantee that if your data is validated - it is correct.

# Super fast and secure

The fastest and the most secure JSON validator

Ajv was designed at the time when there were no validators fully complying with JSON Schema specification, aiming to achieve the best possibly validation performance via just-in-time compilation of JSON schemas to code. Ajv achieved both speed and rigour, but initially security was an afterthought - many security flaws have been fixed thanks to the reports from its users. Ajv version 7 was rebuilt to have secure code generation embedded in its design as the primary objective - even if you use untrusted schemas (which is still not recommended) there are type-level guarantees against remote code execution.

# Multi-specification

Choose your JSON schema standard

In addition to the latest JSON Schema draft 2020-12, Ajv version 8 added support for JSON Type Definition - a new RFC8927 (opens new window) that offers a much simpler and less error-prone alternative to JSON Schema. Designed to be well-aligned with type systems, JTD has tools for both validation and type code generation for multiple languages.

# Introduction (no section heading)

Ajv is a widely used library that provides reliability, safety and security to millions of JavaScript applications and other libraries. It can be used in all JavaScript environments - node.js, browsers, Electron apps, etc. If your environment or security policy prohibit run-time function construction you can compile your schemas during build time into a standalone validation code (it may still have dependencies on small parts of Ajv code, but doesn't use the whole library) - since version 7 it is fully supported for all JSON schemas.

Installation

Usage example / or small playground

Try in the playground (TBC)

# Who uses Ajv

# Contributors

Ajv is free to use and open-source that many developers contributed to. Join us!

epoberezkin PBug90 efim-poberezkin erikbrinkman blakeembrey sambauers gajus meirotstein RadiationSickness domoritz franciscomorais GrahamLea yume-chan boenrobot willfarrell dcbrwn b4h0-c4t igor-savin-ht imbstack pithu awlayton brendo HotelDon donaldpipowitch Fdawgs G-Rath HolgerJeromin monkeywithacupcake marshall007 mattpolzin MichaelDeBoey Nonemoticoner farrago kroky Delagen YChebotaev t7yang teq0 wuweiss ahmdsolmn Alexsey anslzo andyscott kulakowka cbrwflo cpillsbury ChuntaoLu delavara caub dalcib dancasey darcyparker daveisfera keyten thetric forivall ecwyne EtaiG gj rgeerts garrows hans-kinnek handrews idangozlan mrjgreen jonasfj jonathanGB jboavida lehni platinumazure kpping johanlelan leonardovillela LinusU mduu dzuremar mbroadst MattiAstedrone MikeRalphson mychaelgo nwoltman nimerritt nicksrandall Opticsponge orgads philsturgeon carlo-quinonez radekmie RobDesideri merlindorin ryanmeador krenor stuartpb lyngaas bearmini not-an-aardvark koba04 isTravis cvlab villasv wla80 billytrend byr-gdp cjancsar ehmicky fridays jonganc jsdevel ossdev07 rek bhanuprasad14 tridium vlbee aladdin-add duxing anchnk ChALkeR