{"id":13783944,"url":"https://github.com/zaggino/z-schema","last_synced_at":"2026-02-06T01:14:40.143Z","repository":{"id":9658883,"uuid":"11597304","full_name":"zaggino/z-schema","owner":"zaggino","description":"JSON Schema validator written in JavaScript for NodeJS and Browsers","archived":false,"fork":false,"pushed_at":"2024-07-29T16:50:07.000Z","size":9685,"stargazers_count":338,"open_issues_count":38,"forks_count":91,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-10T07:06:11.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaggino.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-07-23T02:13:35.000Z","updated_at":"2025-05-04T23:33:19.000Z","dependencies_parsed_at":"2024-06-18T11:22:06.241Z","dependency_job_id":"b2b94649-9404-42be-b619-8f73d99d0958","html_url":"https://github.com/zaggino/z-schema","commit_stats":{"total_commits":397,"total_committers":39,"mean_commits":"10.179487179487179","dds":0.3198992443324937,"last_synced_commit":"945c94689506eb32e29bb33b2bd6af52cf21c0f4"},"previous_names":[],"tags_count":91,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaggino%2Fz-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaggino%2Fz-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaggino%2Fz-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaggino%2Fz-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaggino","download_url":"https://codeload.github.com/zaggino/z-schema/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198514,"owners_count":22030965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T19:00:33.444Z","updated_at":"2026-02-06T01:14:40.132Z","avatar_url":"https://github.com/zaggino.png","language":"JavaScript","funding_links":[],"categories":["Who Uses the Test Suite","JavaScript","JSON Schema Validators"],"sub_categories":["JavaScript"],"readme":"# z-schema - a JSON Schema validator\n\n[![NPM](https://nodei.co/npm/z-schema.png?downloads=true\u0026downloadRank=true)](https://www.npmjs.com/package/z-schema)\n\n[![Coverage Status](https://coveralls.io/repos/github/zaggino/z-schema/badge.svg?branch=main)](https://coveralls.io/github/zaggino/z-schema?branch=main)\n\n## Topics\n\n- [What](#what)\n- [Versions](#versions)\n- [Usage](#usage)\n- [Features](#features)\n- [Options](#options)\n- [Contributing](#contributing)\n- [Contributors](#contributors)\n\n## What\n\nWhat is a JSON Schema? Find here: [https://json-schema.org/](https://json-schema.org/)\n\n## Versions\n\n- v6 - old version which has been around a long time, supports JSON Schema draft-04\n- v7 - modernized version (to ESM module with Typescript) which passes all tests from JSON Schema Test Suite for draft-04\n- v8 - by default assumes all schemas without $schema tag are draft-04, the old behaviour from v7 can be explicitly turned on by specifying `validator = new ZSchema({ version: 'none' });`\n\n## Usage\n\nValidator will try to perform sync validation when possible for speed, but supports async callbacks when they are necessary.\n\n### ESM and Typescript:\n\n```javascript\nimport ZSchema from 'z-schema';\nconst validator = new ZSchema();\nconsole.log(validator.validate(1, { type: 'number' })); // true\nconsole.log(validator.validate(1, { type: 'string' })); // false\n```\n\n### CommonJs:\n\n```javascript\nconst ZSchema = require('z-schema');\nconst validator = new ZSchema();\nconsole.log(validator.validate(1, { type: 'number' })); // true\nconsole.log(validator.validate(1, { type: 'string' })); // false\n```\n\n### CLI:\n\n```bash\nnpm install --global z-schema\nz-schema --help\nz-schema mySchema.json\nz-schema mySchema.json myJson.json\nz-schema --strictMode mySchema.json myJson.json\n```\n\n### Sync mode:\n\n```javascript\nvar valid = validator.validate(json, schema);\n// this will return a native error object with name and message\nvar error = validator.getLastError();\n// this will return an array of validation errors encountered\nvar errors = validator.getLastErrors();\n...\n```\n\n### Async mode:\n\n```javascript\nvalidator.validate(json, schema, function (err, valid) {\n    ...\n});\n```\n\n### Browser:\n\n```html\n\u003cscript type=\"text/javascript\" src=\"z-schema/umd/ZSchema.min.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\n  var validator = new ZSchema();\n  console.log(validator.validate('string', { type: 'string' }));\n\u003c/script\u003e\n```\n\n### Remote references and schemas:\n\nIn case you have some remote references in your schemas, you have to download those schemas before using validator.\nOtherwise you'll get `UNRESOLVABLE_REFERENCE` error when trying to compile a schema.\n\n```javascript\nvar validator = new ZSchema();\nvar json = {};\nvar schema = { \"$ref\": \"http://json-schema.org/draft-04/schema#\" };\n\nvar valid = validator.validate(json, schema);\nvar errors = validator.getLastErrors();\n// valid === false\n// errors.length === 1\n// errors[0].code === \"UNRESOLVABLE_REFERENCE\"\n\nvar requiredUrl = \"http://json-schema.org/draft-04/schema\";\nrequest(requiredUrl, function (error, response, body) {\n\n    validator.setRemoteReference(requiredUrl, JSON.parse(body));\n\n    var valid = validator.validate(json, schema);\n    var errors = validator.getLastErrors();\n    // valid === true\n    // errors === undefined\n\n}\n```\n\nIf you're able to load schemas synchronously, you can use `ZSchema.setSchemaReader` feature:\n\n```javascript\nZSchema.setSchemaReader(function (uri) {\n  var someFilename = path.resolve(__dirname, '..', 'schemas', uri + '.json');\n  return JSON.parse(fs.readFileSync(someFilename, 'utf8'));\n});\n```\n\n## Features\n\nSee [FEATURES.md](FEATURES.md) for a full list of features.\n\n## Options\n\nSee [OPTIONS.md](OPTIONS.md) for all available options and their descriptions.\n\n## Contributing\n\nThese repository has several submodules and should be cloned as follows:\n\n\u003e git clone **--recursive** https://github.com/zaggino/z-schema.git\n\n## Contributors\n\nBig thanks to:\n\n\u003c!-- readme: contributors,zaggino/- -start --\u003e\n\u003ctable\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/sergey-shandar\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/902339?v=4\" width=\"100;\" alt=\"sergey-shandar\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eSergey Shandar\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/IvanGoncharov\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/8336157?v=4\" width=\"100;\" alt=\"IvanGoncharov\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eIvan Goncharov\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/pgonzal\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/47177787?v=4\" width=\"100;\" alt=\"pgonzal\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003ePete Gonzalez (OLD ALIAS)\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/simon-p-r\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/4668724?v=4\" width=\"100;\" alt=\"simon-p-r\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eSimon R\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/TheToolbox\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/2837017?v=4\" width=\"100;\" alt=\"TheToolbox\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eJason Oettinger\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/whitlockjc\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/98899?v=4\" width=\"100;\" alt=\"whitlockjc\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eJeremy Whitlock\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/epoberezkin\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/2769109?v=4\" width=\"100;\" alt=\"epoberezkin\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eEvgeny\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/toofishes\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/265817?v=4\" width=\"100;\" alt=\"toofishes\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eDan McGee\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/antialias\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/447517?v=4\" width=\"100;\" alt=\"antialias\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eThomas Hallock\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/kallaspriit\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/277993?v=4\" width=\"100;\" alt=\"kallaspriit\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003ePriit Kallas\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/santam85\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/2706307?v=4\" width=\"100;\" alt=\"santam85\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eMarco Santarelli\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/Hirse\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/2564094?v=4\" width=\"100;\" alt=\"Hirse\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eJan Pilzer\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/geraintluff\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/1957191?v=4\" width=\"100;\" alt=\"geraintluff\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eGeraint\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/dgerber\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/393344?v=4\" width=\"100;\" alt=\"dgerber\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eDaniel Gerber\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/addaleax\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/899444?v=4\" width=\"100;\" alt=\"addaleax\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eAnna Henningsen\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/mctep\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/1949681?v=4\" width=\"100;\" alt=\"mctep\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eKonstantin Vasilev\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/barrtender\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/3101221?v=4\" width=\"100;\" alt=\"barrtender\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003ebarrtender\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/RomanHotsiy\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/3975738?v=4\" width=\"100;\" alt=\"RomanHotsiy\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eRoman Hotsiy\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/sauvainr\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/1715747?v=4\" width=\"100;\" alt=\"sauvainr\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eRenaudS\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/figadore\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/3253971?v=4\" width=\"100;\" alt=\"figadore\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eReese\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/MattiSG\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/222463?v=4\" width=\"100;\" alt=\"MattiSG\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eMatti Schneider\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/sandersky\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/422902?v=4\" width=\"100;\" alt=\"sandersky\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eMatthew Dahl\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/jfromaniello\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/178512?v=4\" width=\"100;\" alt=\"jfromaniello\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eJosé F. Romaniello\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/KEIII\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/1167833?v=4\" width=\"100;\" alt=\"KEIII\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eIvan Kasenkov\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\t\u003ctr\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/HanOterLin\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/21137108?v=4\" width=\"100;\" alt=\"HanOterLin\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eTony Lin\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/domoritz\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/589034?v=4\" width=\"100;\" alt=\"domoritz\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eDominik Moritz\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/Semigradsky\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/1198848?v=4\" width=\"100;\" alt=\"Semigradsky\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eDmitry Semigradsky\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/countcain\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/1751150?v=4\" width=\"100;\" alt=\"countcain\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eTao Huang\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/BuBuaBu\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/3825745?v=4\" width=\"100;\" alt=\"BuBuaBu\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eBuBuaBu\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003ctbody\u003e\n\u003c/table\u003e\n\u003c!-- readme: contributors,zaggino/- -end --\u003e\n\nand to everyone submitting [issues](https://github.com/zaggino/z-schema/issues) on GitHub\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaggino%2Fz-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaggino%2Fz-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaggino%2Fz-schema/lists"}