PHPackages                             gromnan/json-crunch - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gromnan/json-crunch

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gromnan/json-crunch
===================

Optimizes JSON responses by minimizing duplication and improving compressibility.

v1.0.0(7y ago)1201MITPHP

Since Jul 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/GromNaN/php-crunch-json)[ Packagist](https://packagist.org/packages/gromnan/json-crunch)[ RSS](/packages/gromnan-json-crunch/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

PHP implementation of the node module [`graphql-crunch`](https://github.com/banterfm/graphql-crunch#readme).

> Optimizes JSON responses by minimizing duplication and improving compressibility.

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

[](#installation)

```
composer require gromnan/json-crunch

```

How does it work?
-----------------

[](#how-does-it-work)

> We flatten the object hierarchy into an array using a post-order traversal of the object graph. As we traverse we efficiently check if we've come across a value before, including arrays and objects, and replace it with a reference to it's earlier occurence if we've seen it. Values are only ever present in the array once.

Usage
-----

[](#usage)

```
use function GromNaN\JsonCrunch\crunch;

$data = json_decode('{"a":["a","b","a"],"b":["a","b","a"]}');

$crunched = crunch($data);

echo json_encode($data, JSON_PRETTY_PRINT);
```

Result:

```
[
    "a",
    "b",
    [0,1,0],
    {"a":2,"b":2}
]
```

Command-line
------------

[](#command-line)

```
bin/crunch-json

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

2861d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/400034?v=4)[Jérôme Tamarelle](/maintainers/GromNaN)[@GromNaN](https://github.com/GromNaN)

---

Top Contributors

[![GromNaN](https://avatars.githubusercontent.com/u/400034?v=4)](https://github.com/GromNaN "GromNaN (6 commits)")

---

Tags

jsonjson-crunchphp-library

### Embed Badge

![Health badge](/badges/gromnan-json-crunch/health.svg)

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

PHPackages © 2026

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