ajv
8.20.0 · 24 Apr 2026MIT544M / weekRepositoryHomepagenpmAtom feed
7.2.4 is the newest release of 7.x.
In short
1 breaking13 removed1 security11 new19 changed
- Breaking
Ajv no longer allows to create the instance without
newkeyword (it is ES6 class). - Removed
errorDataPath - was deprecated, now removed.
- Removed
Format -
validateFormats: falsecan be used instead, old format mode can be chosen via ajv-formats package. - Removed
nullable:
nullablekeyword is supported by default. - Removed
jsonPointers: JSONPointers are used to report errors by default,
jsPropertySyntax: true(deprecated) can be used if old format is needed. - Removed
extendRefs: $ref siblings are validated by default (consistent with draft 2019-09),
ignoreKeywordsWithRef(deprecated) can be used instead to ignore $ref siblings. - Removed
missingRefs: Now exception is always thrown. Pass empty schema with $id that should be ignored to ajv.addSchema.
- Removed
processCode: Replaced with
code: {process: (code, schemaEnv: object) => string}.
Security
1 advisory affects 7.0.0; 8.18.0 fixes them
- Moderateajv has ReDoS when using `$data` optionGHSA-2g4f-4pwh-qvx6 · 11 Feb 2026Fixed in 8.18.0
Release note
Please note: this document covers the changes from v6.12.6.
The main changes
Support of JSON Schema draft-2019-09 features:
unevaluatedPropertiesandunevaluatedItems, dynamic recursive references and other additional keywords.Comprehensive support for standalone validation code - compiling one or multiple schemas to standalone modules with one or multiple exports.
To reduce the mistakes in JSON schemas and unexpected validation results, strict mode is added - it prohibits ignored or ambiguous JSON Schema elements. See Strict mode and Options for more details
- Security
To make code injection from untrusted schemas impossible, code generation is fully re-written to be type-level safe against code injection.
To simplify Ajv extensions, the new keyword API that is used by pre-defined keywords is available to user-defined keywords - it is much easier to define any keywords now, especially with subschemas.
Schemas are compiled to ES6 code (ES5 code generation is supported with an option).
To improve reliability and maintainability the code is migrated to TypeScript.
Separate Ajv classes from draft-07 and draft-2019-09 support with different default imports (see Getting started or v7.0.0-beta.5 for the details).
Please note:
The support for JSON-Schema draft-04 is removed - if you have schemas using "id" attributes you have to replace them with "$id" (or continue using version 6 that will be supported until 02/28/2021).
All formats are separated to ajv-formats package - they have to be explicitly added if you use them.
Ajv instance can only be created with
newkeyword, as Ajv is now ES6 class.Browser bundles are automatically published to ajv-dist package (but still available on cdnjs.com).
Order of schema keyword validation changed - keywords that apply to all types (allOf etc.) are now validated first, before the keywords that apply to specific data types. You can still define custom keywords that apply to all types AND are validated after type-specific keywords using option
post: truein keyword definition.Regular expressions in keywords "pattern" and "patternProperties" are now used as if they had unicode "u" flag, as required by JSON Schema specification - it means that some regular expressions that were valid with Ajv v6 are now invalid (and vice versa).
Better TypeScript support
Methods
compileandcompileAsyncnow return type-guards - see Getting started.Method
validateis a type-guard.Better separation of asynchronous schemas on type level.
Type utility JSONSchemaType<T> that generates the type for JSON Schema for type interface in the type parameter - it simplifies writing schemas (no unions support at the moment).
API changes
addVocabulary - NEW method that allows to add an array of keyword definitions.
addKeyword - keyword name should be passed as property in definition object, not as the first parameter (old API works with "deprecated" warning). Also "inline" keywords support is removed, code generation keywords can now be defined with "code" keyword - the same definition format that is used by all pre-defined keywords
- Breaking
Ajv no longer allows to create the instance without
newkeyword (it is ES6 class).
Added options (and defaults)
strict: True - strict mode
strictTypes: "log" - prevent mistakes related to type keywords and keyword applicability (see Strict Types)
strictTuples: "log" - prevent incomplete tuple schemas (see Prohibit unconstrained tuples)
allowUnionTypes: False - allow multiple non-null types in "type" keyword
allowMatchingProperties: False - allow overlap between "properties" and "patternProperties" keywords
loopEnum: Infinity - optimise validation of enums, similar to
loopRequiredvalidateFormats: True - enable format validation
code: {optimize: number|boolean} - control code optimisation
code: {es5: true} - generate ES5 code, the default is to generate ES6 code.
code: {lines: true} - add line breaks to generated code - simplifies debugging of compiled schemas when you need it
Changed options
keywords- now expects the array of keyword definitions (old API works with "deprecated" warning)
Removed options
- Removed
errorDataPath - was deprecated, now removed.
- Removed
Format -
validateFormats: falsecan be used instead, old format mode can be chosen via ajv-formats package. - Removed
nullable:
nullablekeyword is supported by default. - Removed
jsonPointers: JSONPointers are used to report errors by default,
jsPropertySyntax: true(deprecated) can be used if old format is needed. - Removed
extendRefs: $ref siblings are validated by default (consistent with draft 2019-09),
ignoreKeywordsWithRef(deprecated) can be used instead to ignore $ref siblings. - Removed
missingRefs: Now exception is always thrown. Pass empty schema with $id that should be ignored to ajv.addSchema.
- Removed
processCode: Replaced with
code: {process: (code, schemaEnv: object) => string}. - Removed
sourceCode: Replaced with
code: {source: true}. - Removed
schemaId: Removed, as JSON Schema draft-04 is no longer supported.
- Removed
strictDefaults, strictKeywords, strictNumbers: it is default now, controlled with
strict. - Removed
uniqueItems: '"uniqueItems" keyword is always validated.
- Removed
unknownFormats: The same can be achieved by passing true for formats that need to be ignored via
ajv.addFormatorformatsoption. - Removed
Cache and serialize: Map is used as cache, schema object as key.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.