PHPackages                             justinrainbow/json-schema - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. justinrainbow/json-schema

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

justinrainbow/json-schema
=========================

A library to validate a json schema.

v6.7.2(3mo ago)3.6k316.9M—3.6%368[6 issues](https://github.com/jsonrainbow/json-schema/issues)[1 PRs](https://github.com/jsonrainbow/json-schema/pulls)20MITPHPPHP ^7.2 || ^8.0CI passing

Since Jan 3Pushed 2d ago45 watchersCompare

[ Source](https://github.com/jsonrainbow/json-schema)[ Packagist](https://packagist.org/packages/justinrainbow/json-schema)[ Docs](https://github.com/jsonrainbow/json-schema)[ RSS](/packages/justinrainbow-json-schema/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (84)Used By (20)

JSON Schema for PHP
===================

[](#json-schema-for-php)

[![Build Status](https://github.com/jsonrainbow/json-schema/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/jsonrainbow/json-schema/actions)[![Latest Stable Version](https://camo.githubusercontent.com/569cbcf8cbb710c3d83d4c729c9a7560458a7c33688647d84aadefa6c65c9128/68747470733a2f2f706f7365722e707567782e6f72672f6a757374696e7261696e626f772f6a736f6e2d736368656d612f762f737461626c65)](https://packagist.org/packages/justinrainbow/json-schema)[![Total Downloads](https://camo.githubusercontent.com/2c731fb803673d679f0d8b808d9ce8340a0c23fc49bb41588e4326cf51111499/68747470733a2f2f706f7365722e707567782e6f72672f6a757374696e7261696e626f772f6a736f6e2d736368656d612f646f776e6c6f616473)](https://packagist.org/packages/justinrainbow/json-schema/stats)[![Supported Dialects](https://camo.githubusercontent.com/ecaaf26153e150e33f9d393842c75a9cc9b789b344a931b1dc0c7ae0a0cb0b29/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246737570706f727465645f76657273696f6e732e6a736f6e)](https://camo.githubusercontent.com/ecaaf26153e150e33f9d393842c75a9cc9b789b344a931b1dc0c7ae0a0cb0b29/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246737570706f727465645f76657273696f6e732e6a736f6e)

A PHP Implementation for validating `JSON` Structures against a given `Schema` with support for `Schemas` of Draft-3, Draft-4, Draft-6 or Draft-7.

Features of newer Drafts might not be supported. See [Table of All Versions of Everything](https://json-schema.org/specification-links.html#table-of-all-versions-of-everything) to get an overview of all existing Drafts. See [json-schema](http://json-schema.org/) for more details about the JSON Schema specification

Compliance
==========

[](#compliance)

[![Draft 3](https://camo.githubusercontent.com/10acde2c951d222780e4b55989cd6f0522618f27b09ab8b3dd5d1ed7e0a5bac6/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674332e6a736f6e)](https://camo.githubusercontent.com/10acde2c951d222780e4b55989cd6f0522618f27b09ab8b3dd5d1ed7e0a5bac6/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674332e6a736f6e)[![Draft 4](https://camo.githubusercontent.com/36ba37be059480bd641bbcfe52e5a392b4f8d81fcf1fafdeaddadf543bee3ef8/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674342e6a736f6e)](https://camo.githubusercontent.com/36ba37be059480bd641bbcfe52e5a392b4f8d81fcf1fafdeaddadf543bee3ef8/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674342e6a736f6e)[![Draft 6](https://camo.githubusercontent.com/0314f819b3bcf548a4f302f5254d8f202b49d6d4637b503ac7427f2d83158ebe/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674362e6a736f6e)](https://camo.githubusercontent.com/0314f819b3bcf548a4f302f5254d8f202b49d6d4637b503ac7427f2d83158ebe/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674362e6a736f6e)[![Draft 7](https://camo.githubusercontent.com/d34303869b4787c7eae15c756584f345e558242c6c31332639487f1462fd3915/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674372e6a736f6e)](https://camo.githubusercontent.com/d34303869b4787c7eae15c756584f345e558242c6c31332639487f1462fd3915/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246626f777469652e7265706f72742532466261646765732532467068702d6a757374696e7261696e626f772d6a736f6e2d736368656d61253246636f6d706c69616e63652532466472616674372e6a736f6e)

Installation
------------

[](#installation)

### Library

[](#library)

```
git clone https://github.com/jsonrainbow/json-schema.git
```

### Composer

[](#composer)

[Install PHP Composer](https://getcomposer.org/doc/00-intro.md)

```
composer require justinrainbow/json-schema
```

Usage
-----

[](#usage)

For a complete reference see [Understanding JSON Schema](https://json-schema.org/understanding-json-schema/).

**Note:** Not all drafts might be supported, check the [Bowtie report](https://bowtie.report/#/implementations/php-justinrainbow-json-schema) on the current state of draft implementations.

### Basic usage

[](#basic-usage)

```
