📋 Generate Validation Rules from Example JSON
Writing JSON Schema by hand is painful. AI generates schema from examples. Infer types, required fields, patterns, constraints.
📝 The Prompt
Generate a JSON Schema (draft-07) from these example objects:
Examples:
[{{"id": 1, "name": "Alice", "email": "alice@example.com", "age": 30}},
{{"id": 2, "name": "Bob", "email": "bob@example.com", "age": 25}},
{{"id": 3, "name": "Charlie", "email": "charlie@example.com", "age": 35}}]
Requirements:
- Infer required fields (fields present in all examples)
- Infer types (string, number, boolean, array, object)
- Add format validations (email, date-time, uri)
- Add range constraints for numbers (min, max)
- Add length constraints for strings (minLength, maxLength)
- Add enum if field has limited distinct values
- Add additionalProperties: false
- Include descriptions for each field
Output as valid JSON Schema.
✅ Example Output
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["id", "name", "email", "age"],
"properties": {
"id": {
"type": "integer",
"description": "Unique identifier",
"minimum": 1
},
"name": {
"type": "string",
"description": "Full name of the user",
"minLength": 1,
"maxLength": 100
},
"email": {
"type": "string",
"format": "email",
"description": "Email address"
},
"age": {
"type": "integer",
"description": "Age in years",
"minimum": 0,
"maximum": 150
}
},
"additionalProperties": false
}
💡 Use Cases
- API request/response validation
- Database schema documentation
- Configuration file validation
- Data migration quality checks
- Generate TypeScript interfaces from JSON
“Had 50MB of JSON data from legacy API. Generated schema in seconds. Found that ‘age’ was sometimes string. Fixed API. JSON Schema generation saved days of manual validation.”

