json-schema

Use when working with JSON Schema for validation, including draft-07, 2019-09, and 2020-12 specifications

⭐5stars🔀1forks📁View on GitHub🕐Updated Jan 11, 2026

When & Why to Use This Skill

This Claude skill provides comprehensive support for JSON Schema validation and design, supporting draft-07, 2019-09, and 2020-12 specifications. It streamlines the process of defining data structures, implementing Ajv-based validation logic, and ensuring data integrity across modern software architectures.

Use Cases

  • API Contract Design: Define and validate complex API request and response structures to ensure seamless integration between microservices.
  • Data Validation Logic: Generate production-ready TypeScript or JavaScript code using Ajv to handle real-time data validation in web applications.
  • Schema Version Migration: Upgrade or convert legacy JSON Schemas between different specification versions while maintaining structural integrity.
  • Automated Testing & QA: Create rigorous validation schemas for testing suites to catch data format inconsistencies early in the development lifecycle.
  • Documentation Generation: Use JSON Schemas as a single source of truth to automatically generate technical documentation for data models.
namejson-schema
descriptionUse when working with JSON Schema for validation, including draft-07, 2019-09, and 2020-12 specifications

JSON Schema

Quick Start

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["id", "name"],
  "properties": {
    "id": { "type": "integer", "minimum": 1 },
    "name": { "type": "string", "minLength": 1 },
    "email": { "type": "string", "format": "email" },
    "tags": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true
    }
  },
  "additionalProperties": false
}

Core Keywords

  • Types: string, number, integer, boolean, array, object, null
  • String: minLength, maxLength, pattern, format
  • Number: minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf
  • Array: items, minItems, maxItems, uniqueItems, contains
  • Object: properties, required, additionalProperties, patternProperties
  • Composition: allOf, anyOf, oneOf, not
  • Conditional: if/then/else
  • References: $ref, $defs (or definitions in draft-07)

Common Formats

date-time, date, time, email, uri, uuid, ipv4, ipv6, regex

Ajv (JavaScript Validator)

import Ajv from 'ajv';
import addFormats from 'ajv-formats';

const ajv = new Ajv({ allErrors: true });
addFormats(ajv);

const validate = ajv.compile(schema);
if (!validate(data)) console.log(validate.errors);

Reference Files