PHPackages                             cortexphp/json-repair - 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. cortexphp/json-repair

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

cortexphp/json-repair
=====================

Repair invalid JSON strings by fixing common syntax errors like single quotes, unquoted keys, trailing commas, and missing brackets. Perfect for parsing LLM outputs and malformed API responses.

0.5.0(1w ago)145.9k↓65%MITPHPPHP ^8.3CI passing

Since Jan 25Pushed 1w agoCompare

[ Source](https://github.com/cortexphp/json-repair)[ Packagist](https://packagist.org/packages/cortexphp/json-repair)[ Docs](https://github.com/cortexphp/json-repair)[ RSS](/packages/cortexphp-json-repair/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (6)Dependencies (27)Versions (9)Used By (0)

Repair broken or incomplete JSON strings
========================================

[](#repair-broken-or-incomplete-json-strings)

Repair invalid JSON strings by automatically fixing common syntax errors like single quotes, unquoted keys, trailing commas, and missing brackets.

[![Latest Version](https://camo.githubusercontent.com/8d77f4f208c90b143c2646cb95f9fd6a07b743cc901bcbc2cc03b5142471991b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f727465787068702f6a736f6e2d7265706169722e7376673f7374796c653d666c61742d737175617265266c6f676f3d636f6d706f736572)](https://packagist.org/packages/cortexphp/json-repair)[![GitHub Actions Test Workflow Status](https://camo.githubusercontent.com/9a5cf248e54b2dca699a1a732d268d98ee441f589f7acb8d4c09a553278fadb2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f727465787068702f6a736f6e2d7265706169722f72756e2d74657374732e796d6c3f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://camo.githubusercontent.com/9a5cf248e54b2dca699a1a732d268d98ee441f589f7acb8d4c09a553278fadb2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f727465787068702f6a736f6e2d7265706169722f72756e2d74657374732e796d6c3f7374796c653d666c61742d737175617265266c6f676f3d676974687562)[![GitHub License](https://camo.githubusercontent.com/6fd51904b12e835668c28706c5bf27bac38205ad84049f3256bcce4a52281846/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f727465787068702f6a736f6e2d7265706169723f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://camo.githubusercontent.com/6fd51904b12e835668c28706c5bf27bac38205ad84049f3256bcce4a52281846/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f727465787068702f6a736f6e2d7265706169723f7374796c653d666c61742d737175617265266c6f676f3d676974687562)

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

[](#requirements)

- PHP 8.3+
- JSON PHP extension

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

[](#installation)

```
composer require cortexphp/json-repair
```

Quick Start
-----------

[](#quick-start)

```
use Cortex\JsonRepair\JsonRepairer;

use function Cortex\JsonRepair\json_repair;
use function Cortex\JsonRepair\json_repair_decode;

// Broken JSON (single quotes, unquoted keys, trailing comma)
$broken = "{'name': 'John', age: 30, active: true,}";

$repaired = (new JsonRepairer($broken))->repair();
// {"name": "John", "age": 30, "active": true}

// Or use the helper function
$repaired = json_repair($broken);

// Repair and decode in one step
$data = (new JsonRepairer($broken))->decode();
// ['name' => 'John', 'age' => 30, 'active' => true]

// Or use the helper function
$data = json_repair_decode($broken);
```

Documentation
-------------

[](#documentation)

📚 **[View Full Documentation →](https://docs.cortexphp.com/json-repair)**

Credits
-------

[](#credits)

- [Sean Tymon](https://github.com/tymondesigns)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance98

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.5% 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 ~30 days

Recently: every ~37 days

Total

6

Last Release

8d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2730d341811c79252a25178ab52ee3a83a857cf66b409e9691ecd3e89b6307e0?d=identicon)[tymondesigns](/maintainers/tymondesigns)

---

Top Contributors

[![tymondesigns](https://avatars.githubusercontent.com/u/1801923?v=4)](https://github.com/tymondesigns "tymondesigns (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")

---

Tags

jsonjson-fixerjson-repairjsonjson-fixerjson-repair

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cortexphp-json-repair/health.svg)

```
[![Health](https://phpackages.com/badges/cortexphp-json-repair/health.svg)](https://phpackages.com/packages/cortexphp-json-repair)
```

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k869.4M8.8k](/packages/symfony-http-kernel)[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k144.5M605](/packages/zircote-swagger-php)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[wikimedia/parsoid

Parsoid, a bidirectional parser between wikitext and HTML5

187557.3k3](/packages/wikimedia-parsoid)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[symfony/json-streamer

Provides powerful methods to read/write data structures from/into JSON streams.

18641.1k32](/packages/symfony-json-streamer)

PHPackages © 2026

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