json-schema-library is a customizable, hackable, and highly compliant JSON Schema validator and utility library for JavaScript/TypeScript, fully supporting JSON Schema drafts 04, 06, 07, 2019-09, and 2020-12. Version 11.5.0 is current (released 2024), with frequent updates. Unlike faster or more minimal validators, it prioritizes extensibility: you can customize drafts, add keyword extensions, and traverse schemas via SchemaNode. It's the most compliant validator per Bowtie reports, runs in Node and browser, and ships TypeScript types. Designed for developers building custom tools around JSON Schema, not just validation.
npm install json-schema-libraryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Compiles a JSON Schema into a SchemaNode, validates data, generates default data, and navigates subschemas via JSON Pointer.
Use ES modules: static import or dynamic import(). For legacy CommonJS, stick with v10.x.
Update code to destructure result: const { valid, errors } = schemaNode.validate(data);Parse JSON strings with JSON.parse() first, or import JSON files using import assertions (build tools) or fs.readFileSync with JSON.parse.
Explicitly pass draft option: compileSchema(schema, { draft: 'draft-04' }) to force a specific draft.Change getNode('#/foo') to getNode('#/foo', { data: {} }) to avoid deprecated behavior.Ensure you call compileSchema(schema) first and use the returned SchemaNode. Check import: import { compileSchema } from 'json-schema-library'.Update tsconfig.json: set 'moduleResolution' to 'node' or 'node16', and 'esModuleInterop' to true. Also ensure json-schema-library is installed.
Validate your schema first with a JSON Schema validator or check that properties is an object (not array or string).
Upgrade to v10+ or use a polyfill for self: globalThis.self = globalThis;