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.4.1(2mo ago)122.0k↓31.1%MITPHPPHP ^8.3CI passing

Since Jan 25Pushed 1mo 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 1mo ago

READMEChangelog (5)Dependencies (18)Versions (8)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

45

—

FairBetter than 93% of packages

Maintenance88

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.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 ~13 days

Total

5

Last Release

60d 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 (20 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 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

[justinrainbow/json-schema

A library to validate a json schema.

3.6k316.9M612](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30422.2M45](/packages/colinodell-json5)[clue/ndjson-react

Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.

15467.7M16](/packages/clue-ndjson-react)

PHPackages © 2026

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