npm / ajv
ajv
What changed in ajv 7 to 8, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
29 breaking2 security1 deprecations12 new APIs and options1 performance4 behavior and defaults3 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initajv 814 changes
Breaking changes 5
Ajv adds support for Node.js 22 and 24, and drops support for Node.js 16 and 21.
Fixes Infinity and NaN serialization so they serialize to null.
Validation errors use instancePath instead of dataPath.
JTD errors are now consistent with the JTD specification.
The property name is removed from propertyName keyword error messages and remains available in error.params.propertyName.
Security 2
Fixes prototype pollution via the format keyword when using a $data reference.
Uses the configured RegExp engine with the $data keyword to mitigate ReDoS attacks.
New APIs and options 1
Support was added for dynamic recursive references in JSON Schema draft-2019-09.
Performance 1
Adds sideEffects: false to enable tree-shaking of the package.
Behavior and default changes 2
Error objects include additional properties to simplify error handling.
Validation error messages replace “should” with “must.”
Fixes and other changes 3
Adds ES2022.RegExp support for RegExpIndicesArray.
Fixes resolution of $ref: "#" when $id is present.
Node.js require works without accessing a .default property.
ajv 738 changes
Breaking changes 24
Keyword names must now be passed as a property in the definition object; the old API works with a deprecated warning. Inline keyword support was removed, and code-generation keywords use the code definition property.
Ajv is now an ES6 class and instances can only be created with the new keyword.
Formats are now provided by a separate package and must be explicitly added when used.
Separate Ajv classes are provided for draft-07 and draft-2019-09 support, with different default imports.
The option defaults to false and controls whether the type keyword allows multiple non-null types.
The cache option was removed; a Map is used as the cache, with the schema object as key.
The removed processCode option is replaced by code.process, which receives code and schemaEnv and returns a string.
The removed sourceCode option is replaced by code.source set to true.
JSON Schema draft-04 support was removed; schemas using id attributes must replace them with $id or continue using version 6.
The deprecated option was removed.
Schemas are now compiled to ES6 code by default; ES5 code generation remains available through an option.
$ref siblings are now validated by default; ignoreKeywordsWithRef can be used to ignore them.
The option was removed; validateFormats: false can be used instead, and the old format mode is available through ajv-formats.
JSONPointers are now used to report errors by default; jsPropertySyntax can be used for the old format.
Missing references now always throw an exception; an empty schema with the ignored $id can be passed to addSchema.
The nullable keyword is now supported by default, so the nullable option was removed.
Regular expressions in pattern are now used as if they had the Unicode u flag, which can make some previously valid expressions invalid and vice versa.
Regular expressions in patternProperties are now used as if they had the Unicode u flag, which can make some previously valid expressions invalid and vice versa.
The option was removed because JSON Schema draft-04 is no longer supported.
The serialize option was removed; a Map is used as the cache, with the schema object as key.
Strict mode was added to prohibit ignored or ambiguous JSON Schema elements; its default is true.
The option was removed; strict behavior is now controlled with strict.
The option was removed because the uniqueItems keyword is always validated.
Keywords applying to all types are validated before keywords applying to specific data types; custom all-type keywords can use post: true to run afterward.
Deprecations 1
The option now expects an array of keyword definitions; the old API works with a deprecated warning.
New APIs and options 11
A new method allows adding an array of keyword definitions.
The option defaults to false and controls whether properties and patternProperties may overlap.
Setting es5 to true generates ES5 code instead of the default ES6 code.
Setting lines to true adds line breaks to generated code to simplify debugging compiled schemas.
The optimize option controls code optimization.
A type utility generates a JSON Schema type for the interface supplied as its type parameter; unions are not supported at this time.
The option defaults to Infinity and optimizes validation of enums, similar to loopRequired.
Schemas can be compiled to standalone modules with one or multiple exports.
The option defaults to log and helps prevent incomplete tuple schemas.
The option defaults to log and helps prevent mistakes involving type keywords and keyword applicability.
The option defaults to true and enables format validation.
Behavior and default changes 2
The method now returns a type-guard.
The method is now a type-guard.