{"id":48315,"library":"json-schema","title":"json-schema","description":"Historical library implementing early JSON Schema draft specifications (draft-01 to draft-04). Current version 0.4.0 is considered finished and stable, with no active development. It provides a simple, efficient validator for the original core elements but does not support later drafts (draft-06, draft-07, 2019-09, 2020-12). Used by many legacy npm packages due to its stability and small size. Not suitable for new projects requiring current JSON Schema compliance. Alternatives: ajv (full drafts), @cfworker/json-schema (modern).","status":"maintenance","version":"0.4.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/kriszyp/json-schema","tags":["javascript","json","schema"],"install":[{"cmd":"npm install json-schema","lang":"bash","label":"npm"},{"cmd":"yarn add json-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-schema","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM and CJS both work; CJS via require is more common in older codebases.","wrong":"const validate = require('json-schema').validate","symbol":"validate","correct":"import { validate } from 'json-schema'"},{"note":"Validator class for custom validation options.","wrong":"const Validator = require('json-schema').Validator","symbol":"Validator","correct":"import { Validator } from 'json-schema'"},{"note":"Utility to check a single property change against schema.","symbol":"checkPropertyChange","correct":"import { checkPropertyChange } from 'json-schema'"}],"quickstart":{"code":"import { validate } from 'json-schema';\n\nconst schema = {\n  type: 'object',\n  properties: {\n    name: { type: 'string' },\n    age: { type: 'number', minimum: 0 }\n  },\n  required: ['name']\n};\n\nconst instance = { name: 'Alice', age: 30 };\nconst result = validate(instance, schema);\nif (result.valid) {\n  console.log('Valid!');\n} else {\n  console.log('Errors:', result.errors);\n}","lang":"typescript","description":"Shows JSON Schema validation of an object instance against a schema, checking for errors using the validate function."},"warnings":[{"fix":"Use ajv or @cfworker/json-schema for modern drafts.","message":"Does not support JSON Schema drafts beyond draft-04. Using keywords like 'if/then/else', 'const', or 'contains' will be ignored or cause errors.","severity":"gotcha","affected_versions":">=0.4.0"},{"fix":"Migrate to a maintained library (e.g., ajv).","message":"Package is in maintenance mode; no new features or draft updates will be added.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Clone schema before passing if needed: validate(instance, JSON.parse(JSON.stringify(schema))).","message":"The validate() function mutates the schema object if it has a 'definitions' property (adds a __validated flag).","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Access result.errors[0].property, .message, .schema; not .instancePath, .keyword.","message":"Errors object uses custom properties (property, message, schema) not standard JSON Schema error format.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'-01':13 '-04':16 '-06':47 '-07':49 '-09':51 '-12':53 '0.4.0':19 '2019':50 '2020':52 'activ':27 'ajv':78 'altern':77 'cfworker/json-schema':81 'complianc':76 'consid':21 'core':38 'current':17,73 'develop':28 'draft':10,12,15,45,46,48,80 'due':60 'earli':7 'effici':33 'element':39 'finish':22 'full':79 'histor':4 'implement':6 'javascript':83 'json':2,8,74,84 'json-schema':1 'later':44 'legaci':57 'librari':5 'mani':56 'modern':82 'new':70 'npm':58 'origin':37 'packag':59 'project':71 'provid':30 'requir':72 'schema':3,9,75,85 'simpl':32 'size':66 'small':65 'specif':11 'stabil':63 'stabl':24 'suitabl':68 'support':43 'use':54 'valid':34 'version':18","created_at":"2026-06-07T16:56:00.850084+00:00","updated_at":"2026-06-07T16:56:00.850084+00:00","problems":[{"fix":"Ensure schema is a valid object with type property: const schema = { type: 'object' };","cause":"Schema is null or undefined, or schema lacks expected properties.","error":"TypeError: Cannot read property 'type' of undefined"},{"fix":"Remove $schema from schema or ensure schema is plain object without unrecognized keys.","cause":"Using a $schema keyword for draft-04? This library does not parse $schema and may choke on unknown formats.","error":"Error: Unknown schema format: 'http://json-schema.org/draft-04/schema#'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/kriszyp/json-schema#readme","github":"ssh://git@github.com/kriszyp/json-schema","docs":null,"changelog":null,"pypi":null,"npm":"json-schema","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}