json-schema
Generate and validate JSON Schema definitions. Use when asked to create schemas, validate JSON structure, or document API payloads.
When & Why to Use This Skill
This Claude skill streamlines the creation and validation of JSON Schema definitions, enabling developers to automate data structure documentation, enforce strict validation rules, and ensure API payload consistency across software projects. It simplifies complex schema generation by automatically handling types, constraints, and formatting standards.
Use Cases
- API Design & Documentation: Rapidly generating precise request and response schemas for RESTful or GraphQL APIs to ensure clear communication between frontend and backend teams.
- Data Validation Logic: Creating strict validation rules for configuration files or user-submitted data to prevent system errors and enhance application security.
- Automated Testing: Building schema-based validation suites to verify that system outputs and third-party integrations adhere to required data structures.
- Technical Specification Authoring: Automatically producing detailed documentation for data models, including field descriptions, regex patterns, and mandatory constraints for developer portals.
| name | json-schema |
|---|---|
| description | Generate and validate JSON Schema definitions. Use when asked to create schemas, validate JSON structure, or document API payloads. |
| version | 1.0.0 |
JSON Schema Generator
Overview
Creates JSON Schema definitions for data validation and API documentation.
Instructions
When generating JSON Schema:
- Analyze the data structure or requirements
- Determine types for each field (string, number, object, array, etc.)
- Add constraints: required fields, patterns, min/max values
- Include descriptions for documentation
- Set appropriate
$schemaversion (draft-07 recommended)
Schema Components
Basic Types
string- Text valuesnumber/integer- Numeric valuesboolean- True/falseobject- Nested structuresarray- Lists of itemsnull- Null values
Common Constraints
required- Mandatory fieldsminLength/maxLength- String lengthminimum/maximum- Number boundspattern- Regex validationenum- Allowed valuesformat- Semantic formats (email, uri, date-time)
Examples
Example: User Schema
Input: "Create a schema for a user with name, email, age, and optional phone"
Output:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "User",
"type": "object",
"required": ["name", "email", "age"],
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100,
"description": "User's full name"
},
"email": {
"type": "string",
"format": "email",
"description": "User's email address"
},
"age": {
"type": "integer",
"minimum": 0,
"maximum": 150,
"description": "User's age in years"
},
"phone": {
"type": "string",
"pattern": "^\\+?[1-9]\\d{1,14}$",
"description": "Optional phone number in E.164 format"
}
},
"additionalProperties": false
}
Guidelines
- Always include
$schemadeclaration - Add descriptions for all properties
- Use
additionalProperties: falsefor strict validation - Prefer specific formats over loose patterns