Skip to content

JSON Schema Validator

Validate JSON data against a JSON Schema to ensure structure, types, and constraints are correct

Updated

What is the JSON Schema Validator?

How it works

Examples

Validate a Person Object

Schema: {"type":"object","properties":{"name":{"type":"string","minLength":1},"age":{"type":"integer","minimum":0}},"required":["name","age"]} | Data: {"name":"Alice","age":25}
Valid: true

Detect Type Mismatch

Schema: {"type":"object","properties":{"price":{"type":"number","minimum":0}},"required":["price"]} | Data: {"price":"19.99"}
Valid: false, Errors: [{"path":"price","message":"Expected type number, but got string"}]

Validate with $ref and $defs

Schema: {"$defs":{"address":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}},"type":"object","properties":{"home":{"$ref":"#/$defs/address"}}} | Data: {"home":{"city":"New York"}}
Valid: true

Array Validation with Constraints

Schema: {"type":"array","items":{"type":"string"},"minItems":1,"maxItems":5,"uniqueItems":true} | Data: ["a","b","a","c"]
Valid: false, Errors: [{"path":"[2]","message":"Array items must be unique"}]

String Format Validation

Schema: {"type":"object","properties":{"email":{"type":"string","format":"email"}}} | Data: {"email":"test@example"}
Valid: false, Errors: [{"path":"email","message":"String does not match format: email"}]

Frequently asked questions