JSON Schema Validate + Transform Skill
Validate JSON data against JSON Schema specifications (draft-07, 2019-09, 2020-12) and perform safe, lossless schema migrations and transformations using Ajv (fastest JSON Schema validator) and Zod (TypeScript-first validation).
Open the source and read safety notes before installing.
Prerequisites
- Node.js 18+
- ajv or zod
- TypeScript 4.5+ (for Zod)
- json-schema-to-typescript (optional, for type generation)
- File system read/write access for JSON schema files, data files, and generated TypeScript type definitions
- JSON Schema specification knowledge or reference documentation for creating valid schemas (draft-07, 2019-09, or 2020-12)
Schema details
- Install type
- package
- Reading time
- 5 min
- Difficulty score
- 100
- Troubleshooting
- Yes
- Breaking changes
- No
- Package verified
- Yes
- SHA-256
- 851adc6e2004750ad392111dbccb5a131aec55693c028a0e460cd09f0acb9b8f
- Skill type
- general
- Skill level
- advanced
- Verification
- draft
- Verified at
- 2025-10-15
| Platform | Support | Install path |
|---|---|---|
| claude-code | Native | .claude/skills/<skill-name>/SKILL.md |
| codex | Native | .agents/skills/<skill-name>/SKILL.md |
| windsurf | Native | .windsurf/skills/<skill-name>/SKILL.md |
| gemini | Native | .gemini/skills/<skill-name>/SKILL.md or .agents/skills/<skill-name>/SKILL.md |
| cursor | Adapter | .cursor/rules/<skill-name>.mdc |
| cli | Manual | AGENTS.md or tool-specific context file |
Full copyable content
import Ajv from "ajv";
const ajv = new Ajv({ allErrors: true, strict: true });
const validate = ajv.compile({
type: "object",
properties: { id: { type: "string" } },
required: ["id"],
additionalProperties: false
});
console.log(validate({ id: "abc" })); // true
console.log(validate({})); // false, see validate.errorsAbout this resource
What This Skill Enables
Claude can validate JSON data against schemas, transform data between formats, migrate between schema versions, and generate TypeScript types from JSON schemas using tools like Ajv, Zod, and json-schema-to-typescript.
Compatibility
Native
- Claude Code / Claude: native skill usage via
SKILL.md. - Codex/OpenAI workflows: compatible with Agent Skills-style
SKILL.mdcontent as reusable workflow instructions.
Manual Adaptation
- Gemini CLI: native skill usage via
.gemini/skills/<skill-name>/SKILL.mdor.agents/skills/<skill-name>/SKILL.mdwhere supported. - Cursor: use the generated
.cursor/rules/*.mdcadapter for project rules. - OpenClaw and similar agents: use the same skill content as a reusable prompt/workflow file when native skill import is unavailable.
Prerequisites
Required:
- Claude Pro subscription
- Code Interpreter feature enabled
- JSON data or schema file uploaded
What Claude handles:
- Installing validation libraries (Ajv, Zod)
- Schema compilation and validation
- Error reporting and debugging
- Data transformation and migration
- Type generation from schemas
How to Use This Skill
Validate JSON Against Schema
Prompt: "Validate this JSON data against the provided JSON Schema. Show me all validation errors."
Claude will:
- Load schema and data
- Compile schema
- Run validation
- Report all errors with paths
- Suggest fixes
Generate TypeScript Types
Prompt: "Generate TypeScript interfaces from this JSON Schema."
Claude will:
- Parse the JSON Schema
- Generate TypeScript types
- Include JSDoc comments
- Export as .d.ts file
Transform Data Format
Prompt: "Transform this API response from format A to format B according to this mapping schema."
Claude will:
- Analyze source and target schemas
- Create transformation logic
- Map fields
- Validate output
- Return transformed data
Schema Migration
Prompt: "Migrate these 100 JSON documents from schema v1 to schema v2. Show me the migration script and any issues."
Claude will:
- Compare schema versions
- Identify changes
- Generate migration script
- Process all documents
- Report any migration failures
Common Workflows
API Payload Validation
"Create a validation script that:
1. Loads this OpenAPI spec
2. Extracts the POST /users request schema
3. Validates this payload against it
4. Returns detailed error messages for invalid fields
5. Suggests corrections"
Config File Validation
"Validate all JSON config files in the uploaded directory:
1. Check against config.schema.json
2. Report which files are invalid
3. For each error, show: file, path, expected type, actual value
4. Suggest fixes for common errors
5. Generate a validation report"
Data Normalization
"Normalize this messy JSON data:
1. Validate against the schema
2. Fix common issues (trim strings, coerce types)
3. Remove extra properties not in schema
4. Fill in default values for missing optional fields
5. Export clean, validated JSON"
Batch Transformation
"Transform all JSON files from old format to new:
1. Load transformation rules
2. For each file:
- Parse and validate source
- Apply transformations
- Validate against target schema
- Save to output/
3. Report success/failure stats"
Tips for Best Results
- Provide Complete Schemas: Include all $ref dependencies or use inline definitions
- Specify Validation Rules: Be clear about strictness (additional properties, coercion, etc.)
- Error Reporting: Ask for detailed error paths: "Show me the JSON path for each error"
- Examples: Provide sample valid and invalid data
- Version Info: Specify JSON Schema draft version (draft-07, 2019-09, 2020-12)
- Custom Formats: If using custom formats, define validation logic
- Large Datasets: For many files, ask Claude to process in batches
Advanced Features
Schema Generation
- Generate schema from sample JSON
- Infer types and patterns
- Add validation rules
- Export as JSON Schema or TypeScript
Complex Validations
- Custom validation functions
- Conditional schemas (if/then/else)
- Dependencies between properties
- Pattern properties
- Recursive schemas
Data Transformation Patterns
- Field renaming and mapping
- Nested object flattening/nesting
- Array transformations
- Type coercion with validation
- Conditional transformations
Troubleshooting
Issue: Schema validation too strict Solution: Ask Claude to adjust: "Allow additional properties" or "Coerce types when possible"
Issue: $ref resolution errors Solution: Either inline all schemas or ensure all referenced files are uploaded
Issue: Type coercion not working as expected Solution: Be explicit: "Convert string numbers to integers" or "Parse ISO date strings to Date objects"
Issue: Large JSON files cause memory issues Solution: "Process this file in streaming mode" or "Validate in chunks of 1000 records"
Issue: Validation errors are cryptic Solution: Ask for better errors: "Explain each validation error in plain English with examples"
Issue: Migration breaks data Solution: "Validate each step of the migration" and "Keep backup of original values for rollback"
Learn More
- JSON Schema Specification - Official JSON Schema docs
- Ajv Documentation - The fastest JSON Schema validator
- Zod - TypeScript-first schema validation
- Understanding JSON Schema - Comprehensive guide
- JSON Schema Tools - Validators and generators
Features
- Strict validation with detailed error reporting and JSON path references
- Schema-aware migration between schema versions with change detection
- Format and $ref handling with custom schema loaders
- CLI-friendly usage with batch processing support
- TypeScript type generation from JSON schemas (json-schema-to-typescript)
- Custom validation functions and conditional schemas (if/then/else)
- Data transformation pipelines with type coercion and normalization
- Multiple JSON Schema draft support (draft-07, 2019-09, 2020-12)
Use Cases
- API payload validation against OpenAPI specifications
- Configuration file validation and migration between versions
- Data pipeline guards with schema enforcement
- TypeScript type generation from JSON schemas
- Data normalization and cleaning with schema validation
- Batch transformation of JSON documents between formats
- What This Skill Enables
- Compatibility
- Native
- Manual Adaptation
- Prerequisites
- How to Use This Skill
- Validate JSON Against Schema
- Generate TypeScript Types
- Transform Data Format
- Schema Migration
- Common Workflows
- API Payload Validation
- Config File Validation
- Data Normalization
- Batch Transformation
- Tips for Best Results
Source citations
Signals
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.