PHPackages                             arif-un/jcof - 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. arif-un/jcof

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

arif-un/jcof
============

Compress JSON in half

1.0.2(2y ago)12393MITPHPPHP &gt;=5.6

Since Sep 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Arif-un/jcof-php)[ Packagist](https://packagist.org/packages/arif-un/jcof)[ RSS](/packages/arif-un-jcof/feed)WikiDiscussions main Synced 3w ago

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

JCOF (PHP) JSON Compact Object Format
=====================================

[](#jcof-php-json-compact-object-format)

A more efficient way to represent JSON-style objects.

About
-----

[](#about)

JCOF tries to be a drop-in replacement for JSON, with most of the same semantics, but with a much more compact representation of objects. The main way it does this is to introduce a string table at the beginning of the object, and then replace all strings with indexes into that string table. It also employs a few extra tricks to make objects as small as possible, without losing the most important benefits of JSON. Most importantly, it remains a text-based, schemaless format.

Example JSON object (299 byte):\*\*\*\*

```
{
	"people": [
		{"first-name": "Bob", "age": 32, "occupation": "Plumber", "full-time": true},
		{"first-name": "Alice", "age": 28, "occupation": "Programmer", "full-time": true},
		{"first-name": "Bernard", "age": 36, "occupation": null, "full-time": null},
		{"first-name": "El", "age": 57, "occupation": "Programmer", "full-time": false}
	]
}
```

Coverted JCOF object (134 byte) 55% lower :

```
Programmer;"age""first-name""full-time""occupation";
{"people"[(0,iw"Bob"b"Plumber")(0,is"Alice"b,s0)(0,iA"Bernard"n,n)(0,iV"El"B,s0)]}

```

### Benchmark

[](#benchmark)

[![json-vs-jcof-benchmark](https://github.com/Arif-un/jcof-php/raw/main/benchmark.png?raw=true)](https://github.com/Arif-un/jcof-php/blob/main/benchmark.png?raw=true)

### Install

[](#install)

You can install Jcof through [Composer](https://getcomposer.org/):

```
composer require arif-un/jcof
```

### Usage

[](#usage)

stringify PHP associative array (json\_encode)

```
use Jcof;

$jsonString = file_get_contents(__DIR__ . '/madrid.json');

$dataAssocArray = json_decode($jsonString, true); // covert to an associative array

$jcofCompressedStr = Jcof::stringify($dataAssocArray); // compressed string
```

convert back to JSON

```
use Jcof;

$dataAssocArray = Jcof::parse($jcofCompressedStr); // covert jcof compressed string to associative array

$jsonData = json_encode($dataAssocArray); // coverted json
```

### Other language implementation

[](#other-language-implementation)

- JCOF Javascript [NPM](https://www.npmjs.com/package/jcof)

\#### This repository is php implementation of \[javascript version\]().

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.9% 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 ~0 days

Total

2

Last Release

1001d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3d247b43dee474edc2f1574b99b71a7fc7a01a8dd1d983530b26858e7617675?d=identicon)[Arif-un](/maintainers/Arif-un)

---

Top Contributors

[![Arif-un](https://avatars.githubusercontent.com/u/19432983?v=4)](https://github.com/Arif-un "Arif-un (10 commits)")[![mdrubelamin2](https://avatars.githubusercontent.com/u/43474737?v=4)](https://github.com/mdrubelamin2 "mdrubelamin2 (3 commits)")

---

Tags

jcofjson-compressjson-optimize

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/arif-un-jcof/health.svg)

```
[![Health](https://phpackages.com/badges/arif-un-jcof/health.svg)](https://phpackages.com/packages/arif-un-jcof)
```

###  Alternatives

[sinergi/dictionary

PHP Dictionary library

1514.9k2](/packages/sinergi-dictionary)

PHPackages © 2026

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