JSON validates syntax (is it parseable). JSON Schema validates structure (does it match what your API expects).
Example JSON:
{
"id": 42,
"email": "[email protected]",
"role": "admin",
"active": true
}
Example schema (simplified):
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"required": ["id", "email", "role"],
"properties": {
"id": { "type": "integer", "minimum": 1 },
"email": { "type": "string", "format": "email" },
"role": { "type": "string", "enum": ["admin", "editor", "viewer"] },
"active": { "type": "boolean" }
}
}
If you receive “valid JSON but wrong data”, schema validation tells you which field is missing or wrong—much faster than manual debugging.
Related: Validate JSON syntax · API JSON best practices