Skip to content
JSON Schema Logo + PHP Logo

JSON Schema for PHP

Validate, interpret, and work with JSON Schemas in PHP — fully compatible with the specifications.

Standards Compliant

Implements the official JSON Schema specification (Draft 3 and 4), ensuring predictable and reliable validation.

Developer Friendly

Simple, expressive API designed for modern PHP projects. Integrates easily into frameworks like Laravel, Symfony, and more.

Robust validation engine

Validate data against schemas with precision and speed, independently verified through the Bowtie compliance suite.

Example



$schema = json_decode(file_get_contents('person.schema.json'));
$data = json_decode('{"name": "Alice", "age": 30}');

$validator = new \JsonSchema\Validator();
$validator->validate($data, $schema);

if ($validator->isValid()) {
    echo "✅ The supplied JSON validates against the schema.\n";
} else {
    echo "❌ JSON does not validate. Violations:\n";
    foreach ($validator->getErrors() as $error) {
        printf("[%s] %s\n", $error['property'], $error['message']);
    }
}