Migrates JSON Schema between drafts: draft-04 to draft-07, draft-2019-09, or draft-2020-12. Current stable version is 2.0.0. Maintained as part of the Ajv validator ecosystem. Key differentiators: supports multiple target drafts, handles draft-04-specific patterns like boolean exclusiveMinimum, single-value enum to const, and empty/not schemas. Release cadence is low; updates are infrequent. Alternatives include manual schema transformation or using Ajv's own migration utilities, but this package provides a dedicated, focused tool.
npm install json-schema-migrateNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows migrating a draft-04 schema with boolean exclusiveMinimum to draft-07, using default import and draft7 function.
Clone the schema first: const cloned = JSON.parse(JSON.stringify(original));
Use 'const' directly in your source schema.
After migration, use '$defs' instead of 'definitions'.
Update Node to >=6.0.0 and replace 'migrate.ajv' with 'migrate.getAjv()'.
After migration, update any logic that accesses schema.items to handle the new prefixItems structure.
Ensure the schema object is mutable (not frozen or from a read-only source like Object.freeze).
Use const migrate = require('json-schema-migrate'); (CJS) or dynamic import with .default property: const migrate = (await import('json-schema-migrate')).default;Ensure the schema is a valid JSON Schema draft-04 object; check for missing required properties or malformed keywords.