PHPackages                             cmpayments/jsonlint - 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. cmpayments/jsonlint

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

cmpayments/jsonlint
===================

JSON Lint for PHP checks a string for invalid or malformed JSON, control character error, incorrect encoding or just plain old syntax errors. It returns comprehensive feedback in a one-line error message (one-line message especially meant for REST APIs) about the first error that occurred in the (JSON) string. It supports both RFC 4627 and (its superseding) RFC 7159.

v0.0.5(10y ago)74.7k1MITPHPPHP ^5.4 || ^7.0

Since Dec 17Pushed 10y ago4 watchersCompare

[ Source](https://github.com/cmpayments/jsonlint)[ Packagist](https://packagist.org/packages/cmpayments/jsonlint)[ Docs](https://github.com/cmpayments/jsonlint)[ RSS](/packages/cmpayments-jsonlint/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (6)Used By (1)

JSON Lint for PHP [![Build Status](https://camo.githubusercontent.com/edf02b47749fffb16a984accf627504d20cafa6ecd33e546783a89ddf0fc43af/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636d7061796d656e74732f6a736f6e6c696e742e737667)](https://travis-ci.org/cmpayments/jsonlint)
==============================================================================================================================================================================================================================================================================================

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

[![License](https://camo.githubusercontent.com/2ab9a5bbc9b310b9874084539f3368c1ac190779b83ffd9fcc8d21714d0c8fc1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636d7061796d656e74732f6a736f6e6c696e742e737667)](https://camo.githubusercontent.com/2ab9a5bbc9b310b9874084539f3368c1ac190779b83ffd9fcc8d21714d0c8fc1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636d7061796d656e74732f6a736f6e6c696e742e737667)[![Latest Stable Version](https://camo.githubusercontent.com/d404fb36aeefd9ac616883f25e5e23de43da20e1336a5079f1ab4e14e5eb2547/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636d7061796d656e74732f6a736f6e6c696e742e737667)](https://packagist.org/packages/cmpayments/jsonlint)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/37f1e197020360ace5ce07f3cbc438cf522503b0cff7df6317748a005c5d0adb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636d7061796d656e74732f6a736f6e6c696e742f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/cmpayments/jsonlint/)[![Total Downloads](https://camo.githubusercontent.com/64f210aebd82c787af6f0f067860748471338c449643b518f5d7b11878b8b43b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636d7061796d656e74732f6a736f6e6c696e742e737667)](https://packagist.org/packages/cmpayments/jsonlint)[![Reference Status](https://camo.githubusercontent.com/d42a4f8bdb604fb9f7b1a96996ac94dddc73c7095c086c6258808b40a4e8dba8/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f636d7061796d656e74733a6a736f6e6c696e742f7265666572656e63655f62616467652e737667)](https://www.versioneye.com/php/cmpayments:jsonlint/references)

JSON Lint for PHP checks a string for invalid or malformed JSON, control character error, incorrect encoding or just plain old syntax errors. It returns comprehensive feedback in a one-line error message (one-line message especially meant for REST APIs) about the first error that occurred in the (JSON) string. It supports both RFC 4627 and (its superseding) RFC 7159.

Usage
-----

[](#usage)

```
use CMPayments\JsonLint\JsonLinter;

$linter = new JsonLinter();

// example JSON
$json = '{
    "id": 2,
    "name": "JSON Parser test",
    \'dimensions\': {
        "length": 7.0,
        "width": 12.0,
        "height": 9.5
    }
}';

// returns null if it's valid json, or a ParseException object.
$result = $linter->lint($json);

// Call $result->getMessage() on the ParseException object to get a well formatted error message error like this:
// You used single quotes instead of double quotes on string 'dimensions' on line 4 at column 9. It appears you have an extra trailing comma

// Call $result->getDetails() on the exception to get more info.
$result->getDetails();

// $result->getDetails() returns;
array (size=6)
  'errorCode' => int 3
  'match' => string 'dimensions' (length=10)
  'token' => string 'INVALID' (length=7)
  'line' => int 3
  'column' => int 9
  'expected' =>
    array (size=1)
      0 => string 'STRING' (length=6)
```

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

[](#installation)

For a quick install with Composer use:

```
$ composer require cmpayments/jsonlint

```

JSON Lint for PHP can easily be used within another app if you have a [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md)autoloader, or it can be installed through [Composer](https://getcomposer.org/).

Requirements
------------

[](#requirements)

- PHP 5.4+
- \[optional\] PHPUnit 3.5+ to execute the test suite (phpunit --version)

Submitting bugs and feature requests
------------------------------------

[](#submitting-bugs-and-feature-requests)

Bugs and feature request are tracked on [GitHub](https://github.com/cmpayments/jsonlint/issues)

Todo
----

[](#todo)

- Add support for keys without double quotes\*

\*RFC 4627 states that an object is an unordered collection of zero or more key/value pairs, where a key is a string and a value is a string, number, boolean, null, object, or array. This JSON linter tends to be more lenient towards keys without quotes in order to accept request from a JavaScript frontend.

Author
------

[](#author)

Boy Wijnmaalen -  -

License
-------

[](#license)

JSON Lint is licensed under the MIT License - see the LICENSE file for details

Acknowledgements
----------------

[](#acknowledgements)

This library is based on [Seldaek/jsonlint](https://github.com/Seldaek/jsonlint) and [zaach/jsonlint](https://github.com/zaach/jsonlint).

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.2% 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

Every ~25 days

Total

5

Last Release

3752d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1016795?v=4)[Bas Peters](/maintainers/baspeters)[@baspeters](https://github.com/baspeters)

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

---

Top Contributors

[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (58 commits)")[![martinlindhe](https://avatars.githubusercontent.com/u/181531?v=4)](https://github.com/martinlindhe "martinlindhe (4 commits)")[![baspeters](https://avatars.githubusercontent.com/u/1016795?v=4)](https://github.com/baspeters "baspeters (3 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (3 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (2 commits)")[![firegate666](https://avatars.githubusercontent.com/u/1197926?v=4)](https://github.com/firegate666 "firegate666 (2 commits)")[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (2 commits)")[![MAXakaWIZARD](https://avatars.githubusercontent.com/u/1138453?v=4)](https://github.com/MAXakaWIZARD "MAXakaWIZARD (2 commits)")[![asnyder](https://avatars.githubusercontent.com/u/199062?v=4)](https://github.com/asnyder "asnyder (2 commits)")[![miclf](https://avatars.githubusercontent.com/u/3188746?v=4)](https://github.com/miclf "miclf (1 commits)")[![omnicolor](https://avatars.githubusercontent.com/u/206237?v=4)](https://github.com/omnicolor "omnicolor (1 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (1 commits)")[![DavidPrevot](https://avatars.githubusercontent.com/u/3936728?v=4)](https://github.com/DavidPrevot "DavidPrevot (1 commits)")[![simensen](https://avatars.githubusercontent.com/u/191200?v=4)](https://github.com/simensen "simensen (1 commits)")[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (1 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (1 commits)")

---

Tags

phpjsonvalidatorparserlinterlintsyntaxsyntaxcheck

### Embed Badge

![Health badge](/badges/cmpayments-jsonlint/health.svg)

```
[![Health](https://phpackages.com/badges/cmpayments-jsonlint/health.svg)](https://phpackages.com/packages/cmpayments-jsonlint)
```

###  Alternatives

[seld/jsonlint

JSON Linter

1.3k228.7M271](/packages/seld-jsonlint)[neilime/php-css-lint

Powerful &amp; memory efficient CSS linter for PHP

131.9M3](/packages/neilime-php-css-lint)[dragon-code/codestyler

A tool to automatically fix Coding Style Standards issues by The Dragon Code.

291.9M28](/packages/dragon-code-codestyler)[evaisse/php-json-schema-generator

A JSON Schema Generator.

20316.0k1](/packages/evaisse-php-json-schema-generator)

PHPackages © 2026

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