Registry / developer-tools / json-schema-compatibility

json-schema-compatibility

JSON →
library1.1.0jsnpmunverified

Converts JSON Schema v3 schemas to v4 compatibility, solving the problem of migrating legacy schemas to the newer draft. Version 1.1.0 is the latest stable release; the project appears to be in maintenance mode with no recent updates. Unlike alternatives that require manual rewriting, this tool works in-place on schema objects and supports merged syntaxes like mixed boolean/array 'required'. Released under public domain and MIT licenses.

npm install json-schema-compatibility
INSTALL
IMPORT
SIG · JSON-SCHEMA-COMPAT
J
json-schema-compatibility
developer-toolsjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

v4
var api = require('json-schema-compatibility'); api.v4(schema);
const { v4 } = require('json-schema-compatibility');
CommonJS required. The module exports a function with a 'v4' method; destructuring may work but not standard.
JsonSchemaCompatibility
<script src="json-schema-compatibility.min.js"></script> // then JsonSchemaCompatibility.v4(schema)
import JsonSchemaCompatibility from 'json-schema-compatibility';
Browser global only; no ESM support.
v4 (ESM)
import jsonSchemaCompatibility from 'json-schema-compatibility'; jsonSchemaCompatibility.v4(schema);
import { v4 } from 'json-schema-compatibility';
Default import works via ESM interop, but not officially supported.

Shows converting a v3 schema to v4 using Node.js require and the v4 function.

var api = require('json-schema-compatibility'); var v3Schema = {"type": "number", "divisibleBy": 1.5}; var v4Schema = api.v4(v3Schema); console.log(JSON.stringify(v4Schema)); // Output: {"type":"number","multipleOf":1.5}
Debug
Known issues
gotchaThe tool modifies the schema object in-place; do not rely on the original object after conversion.
fix
Clone the schema first if you need the original: var copy = JSON.parse(JSON.stringify(original)); api.v4(copy);
affects: >=1.0.0
deprecatedThe package has not been updated since 2014; v4 is now outdated (JSON Schema draft-07 and later exist).
fix
Use a more modern library (e.g., ajv with addSchema for multiple drafts) or manually update to latest draft.
affects: >=1.0.0
gotchaBrowser usage requires a global shim for Array.isArray and other ES5 features.
fix
Include an ES5 shim (e.g., es5-shim) before this library in older browsers.
affects: >=1.0.0
gotchaThe package does not support ESM imports natively; attempting import may fail.
fix
Use CommonJS require or bundler's CommonJS interop (e.g., webpack with commonjs option).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: api.v4 is not a function
Incorrect import path or module not installed.
fix
Ensure package is installed: npm install json-schema-compatibility; then use var api = require('json-schema-compatibility');
Uncaught ReferenceError: JsonSchemaCompatibility is not defined
Missing script include or script loading order in browser.
fix
Include the library script before using: <script src='path/to/json-schema-compatibility.js'></script>
JSON Schema validation error: unknown keyword 'divisibleBy'
Schema still in v3 format; tool not applied correctly.
fix
Pass the schema through api.v4() to convert 'divisibleBy' to 'multipleOf'.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
43 hits · last 30 days
node
36
OpenAI (training)
1
Resources
json-schema-compatibility — npm install json-schema-compatibility · libregistry