PHPackages                             mszewcz/php-json-schema-validator - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. mszewcz/php-json-schema-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

mszewcz/php-json-schema-validator
=================================

JSON Schema Validator with draft-06 specification support

1.0.0(8y ago)192MITPHPPHP &gt;=7.1.0

Since Nov 2Pushed 8y agoCompare

[ Source](https://github.com/mszewcz/php-json-schema-validator)[ Packagist](https://packagist.org/packages/mszewcz/php-json-schema-validator)[ RSS](/packages/mszewcz-php-json-schema-validator/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

php-json-schema-validator
=========================

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

JSON schema validator class, which provides validation of JSON files according to draft-06 specification, published on 2017-04-15.

[![Build Status](https://camo.githubusercontent.com/277e06d0226dd3979230f58765f0ffdeb31710cc07487a5ca20bd81d8c61d859/68747470733a2f2f7472617669732d63692e636f6d2f6d737a6577637a2f7068702d6a736f6e2d736368656d612d76616c696461746f722e7376673f746f6b656e3d534b487955753744396b326778667935614b7058266272616e63683d646576656c6f70)](https://travis-ci.com/mszewcz/php-json-schema-validator)[![Codacy Badge](https://camo.githubusercontent.com/34a4c14690de044d1896c33e7e9124c8793c99135181f1d893407915cd449921/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3732353036353561353165373437633662643564303939643432343065396366)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=mszewcz/php-json-schema-validator&utm_campaign=Badge_Grade)[![Codacy Badge](https://camo.githubusercontent.com/20064edd0990a88a283e51b92156a7dbcd39f68cd900bc0d319df24fde462b4e/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f436f7665726167652f3732353036353561353165373437633662643564303939643432343065396366)](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=mszewcz/php-json-schema-validator&utm_campaign=Badge_Coverage)

Contents
--------

[](#contents)

- [Installation](#Installation)
- [Usage](#Usage)
- [Supported Elements](#SupportedElements)
- [Contributing](#Contributing)
- [License](#License)

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

[](#installation)

If you use [Composer](http://getcomposer.org/) to manage the dependencies simply add a dependency on `mszewcz/php-json-schema-validator` to your project's composer.json file. Here is a minimal example of a composer.json:

```
{
    "require": {
        "mszewcz/php-json-schema-validator": ">=1.0"
    }
}

```

You can also clone or download this respository.

**php-json-schema-validator** meets [PSR-4](http://www.php-fig.org/psr/psr-4/) autoloading standards. If using the Composer please include its autoloader file:

```
require_once 'vendor/autoload.php';
```

If you cloned or downloaded this repository, you will have to code your own PSR-4 style autoloader implementation.

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';

try {
    $utils      = new MS\Json\Utils\Utils();
    $schema     = $utils->decode($jsonSchemaDefinition);
    $json       = $utils->decode($jsonToValidate);
    $validator  = new MS\Json\SchemaValidator\Validator($schema);
    $result     = $validator->validate($json);
} catch (\Exception $e) {
    echo $e->getMessage();
}
```

If you don't want to use Utils class to decode JSONs, you should do that the following way:

```
$schema = \json_decode($jsonSchemaDefinition, true);
$json   = \json_decode($jsonToValidate, true);
```

Supported elements
------------------

[](#supported-elements)

**php-json-schema-validator** supports validation against:

- additionalItems
- additionalProperties
- allOf
- anyOf
- const
- contains
- dependencies
- enum
- exclusiveMaximum
- exclusiveMinimum
- format (date-time, email, host, ipv4, ipv6 &amp; uri)
- items
- maximum
- minimum
- maxItems
- maxLength
- maxProperties
- minItems
- minLength
- minProperties
- multipleOf
- not
- oneOf
- pattern
- patternProperties
- properties
- propertyNames
- required
- type
- uniqueItems

**It also supports `$ref` element, so you can use in-json definitions and references without any problems.**

Contributing
------------

[](#contributing)

Contributions are welcome. Please send your contributions through GitHub pull requests

Pull requests for bug fixes must be based on latest stable release from the `master` branch whereas pull requests for new features must be based on the `developer` branch.

Due to time constraints, I'm not always able to respond as quickly as I would like. If you feel you're waiting too long for merging your pull request please remind me here.

#### Coding standards

[](#coding-standards)

We follow [PSR-2](http://www.php-fig.org/psr/psr-2/) coding style and [PSR-4](http://www.php-fig.org/psr/psr-4/) autoloading standards. Be sure you're also following them before sending your pull request.

License
-------

[](#license)

**php-json-schema-validator** is licensed under the MIT License - see the `LICENSE` file for details.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3111d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c747ca08b7ba62fdbcc2708171026a6a7fe6d841fecacb705c31a5332a3c61da?d=identicon)[mszewcz](/maintainers/mszewcz)

---

Top Contributors

[![mszewcz](https://avatars.githubusercontent.com/u/31341235?v=4)](https://github.com/mszewcz "mszewcz (10 commits)")

---

Tags

phpjsonschemavalidatorphp-json-schema-validator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mszewcz-php-json-schema-validator/health.svg)

```
[![Health](https://phpackages.com/badges/mszewcz-php-json-schema-validator/health.svg)](https://phpackages.com/packages/mszewcz-php-json-schema-validator)
```

###  Alternatives

[opis/json-schema

Json Schema Validator for PHP

64236.9M185](/packages/opis-json-schema)[ergebnis/json-schema-validator

Provides a JSON schema validator, building on top of justinrainbow/json-schema.

3626.9M7](/packages/ergebnis-json-schema-validator)[geraintluff/jsv4

A (coercive) JSON Schema v4 Validator for PHP

115455.2k3](/packages/geraintluff-jsv4)[johnstevenson/json-works

Create, edit, query and validate json

272.5M6](/packages/johnstevenson-json-works)[evaisse/php-json-schema-generator

A JSON Schema Generator.

20298.5k1](/packages/evaisse-php-json-schema-generator)[dstotijn/yii2-json-schema-validator

A Yii2 extension that provides a validator class for JSON Schema validation.

1730.7k](/packages/dstotijn-yii2-json-schema-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
