Fast, lightweight JSON Schema validator for Node.js and browsers supporting all major drafts from draft-04 through draft-2020-12. Version 12.3.1, maintained actively with regular releases. Key differentiators: TypeScript-first, ESM/CJS/UMD support, synchronous and asynchronous validation modes, safe (non-throwing) API, schema compilation with $ref resolution. Requires Node.js 22+. Full test coverage, CLI tool included. Distinguishes from Ajv by offering throw/safe modes natively and simpler API.
npm install z-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
ESM/TypeScript quickstart: create a validator, validate an object against a schema, handle errors via try/catch.
Use dynamic import: const ZSchema = (await import('z-schema')).defaultReplace new ZSchema() with ZSchema.create()
Use strictMode: true instead of manual flags
Pass { safe: true } to create() for non-throwing validationCatch ValidateError and read .details array
Update script src or use npm CDN with correct path
Use dynamic import: const ZSchema = (await import('z-schema')).defaultUse ZSchema.create() to get a validator instance
npm install z-schema or check import path
Create validator with { async: true } and await validate()