JSON validation with z-schema
Validates JSON against a schema with z-schema and turns errors into clear field messages, so bad input is caught.
What we improved
Ran every example against z-schema 12.9.0 on Node 22 and said so at the top, with how to check the installed version and what to do on versions before 9. Added a short workflow: check the schema first, pick a mode, translate errors, and pro
Improved by YourAISkill from the original by Kilo-Org, under its Apache-2.0 licence. The download includes the author's licence and a CHANGES.md listing every change. Both Claude reviews read the improved version.
Claude's review
8/10 Accurate, tested z-schema v12 guide covering modes, error translation, refs, formats, CLI and real gotchas; narrow audience but excellent for it.
We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.
In detail
Validates JSON data against JSON Schema using the z-schema library. Use when the user needs to validate JSON, check data against a schema, handle validation errors, use custom format validators, work with JSON Schema drafts 04 through 2020-12, set up z-schema in a project, compile schemas with cross-references, resolve remote $ref, configure validation options, or inspect error details. Covers sync/async modes, safe error handling, schema pre-compilation, remote references, TypeScript types, and browser/UMD usage.
How you use it
- Add it to your pack, then download your pack (1 credit).
- In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
- Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide
Safety check
Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.
An automated scan lowers risk but cannot promise zero risk. How we check skills
Preview
The first lines of SKILL.md
---
name: validating-json-data
description: >-
Validates JSON data against JSON Schema (draft-04 to draft-2020-12) with the
z-schema library (v12) in Node.js, the browser or its CLI, and turns its
errors into messages people can act on. Use when a project already uses
z-schema or the user asks for it by name: setting up or upgrading z-schema,
choosing between its throwing, safe and async modes, compiling schemas that
reference each other, resolving remote $ref, adding custom or async format
checks, reading nested anyOf/oneOf errors, running the z-schema CLI in CI, or
debugging why a z-schema validation rejects (or silently accepts) data. Not
for projects built on another validator such as Ajv, Zod, Joi or Python's
jsonschema.
metadata:
category: development
source:
repository: 'https://github.com/zaggino/z-schema'
path: skills/validating-json-data
license_path: LICENSE
commit: 221f6d9d15a7adc117c2872ea657ab3a6c0aeedf
---
<!-- Modified by YourAISkill (youraiskill.com) on 2 December 2026 from the original by Kilo-Org. See CHANGES.md. -->
# Validating JSON Data with z-schema
z-schema validates JSON data against JSON Schema (draft-04, draft-06, draft-07, draft-2019-09, draft-2020-12). Default draft: **draft-2020-12**.
Every example below was run against **z-schema 12.9.0 on Node 22** (the package requires Node 22 or later). Check what the project has with `npm ls z-schema`. Versions before 9 use `new ZSchema()` and a different API; if the project is on one of those, say so and either upgrade or follow that version's README instead of this file.
## Workflow
1. **Find the schema and the data.** Note which draft the schema targets: its `$schema` line, or the keywords it uses (`definitions` and `id` suggest draft-04/07; `$defs` and `prefixItems` suggest 2020-12). See the draft table in [references/draft-comparison.md](references/draft-comparison.md).
2. **Check the schema itself first** with `validateSchemaSafe(schema)` (or the CLI with only the schema). A broken schema produces confusing data errors later.
3. **Pick a mode** (table below). Use async only if a format validator is async.
4. **Validate, then translate errors** into field plus message (see "Turning errors into messages"). Never show users `err.message`: for data errors it is a code such as `JSON_OBJECT_VALIDATION_FAILED`, not a sentence.
5. **Prove it both ways.** Run one sample that must pass and at least one that must fail for each rule you care about. A schema that accepts everything looks exactly like a working one until you test a bad sample (see Gotchas: unknown formats are silently ignored).
## Quick start
```typescript
...From Kilo-Org's repository, Apache-2.0 licence.
Related skills
-
Checked
Port code to Rust
Ports C, C++, Python, Go or JavaScript code into idiomatic Rust, with tests that prove it behaves the same.
8/101 credit -
Checked
TypeScript MCP Server Builder
Builds a tested MCP server in TypeScript on the current SDK, so Claude and other AI apps can use your tools.
7/101 credit -
Checked
Scrolling menu upgrade
Finds outdated react-horizontal-scrolling-menu code and rewrites it for version 8 so the menu works again.
7/101 credit -
Checked
Deno Deploy Hosting
Deploys Deno apps to the new Deno Deploy with a database and scheduled jobs, and moves old projects across.
7/101 credit -
Checked
ESLint Setup
Sets up ESLint with the current flat config for TypeScript and React, and makes CI enforce it.
7/101 credit -
Checked
Modern Node.js Features
Uses modern Node.js features like the built in test runner, TypeScript support and env files, not extra packages.
7/101 credit