PHPackages                             rcubitto/json-pretty - 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. rcubitto/json-pretty

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

rcubitto/json-pretty
====================

Pretty print your PHP arrays with style – in full color and with proper indentation

1.0(5y ago)473.3k↓43.4%3[2 issues](https://github.com/rcubitto/json-pretty/issues)[1 PRs](https://github.com/rcubitto/json-pretty/pulls)MITPHPPHP ^7.3|^8.0CI failing

Since Mar 20Pushed 3y agoCompare

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

READMEChangelogDependencies (1)Versions (8)Used By (0)

JSON Pretty Print
=================

[](#json-pretty-print)

[![Latest Version on Packagist](https://camo.githubusercontent.com/af3774e541fa4ace3e36c3d219c6e2ce5b1e5364dd1eecc1268dfe2acd3b8951/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726375626974746f2f6a736f6e2d7072657474792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rcubitto/json-pretty)[![Build Status](https://camo.githubusercontent.com/2a1116b7efec9642dfcb5e9fdf23ac4d48c32469f964aaee941547a7e671c2e3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f726375626974746f2f6a736f6e2d7072657474792f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/rcubitto/json-pretty)[![Quality Score](https://camo.githubusercontent.com/93a491c4cfafa8e3a403d2dc97e2b8e108d6513dd4369bb0504bbcd9ecbd1190/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f726375626974746f2f6a736f6e2d7072657474792e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/rcubitto/json-pretty)[![Total Downloads](https://camo.githubusercontent.com/9f1babf24eb15b8bcb9c52e33fd8e8c130d696b6126cef9c9f67cf832397f828/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726375626974746f2f6a736f6e2d7072657474792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rcubitto/json-pretty)

JSON Pretty is a very simple library that prints a JSON array in full color with proper indentation.

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

[](#installation)

You can install the package via composer:

```
composer require rcubitto/json-pretty
```

Usage
-----

[](#usage)

You can print any array, both sequencial and associate.

```
\Rcubitto\JsonPretty\JsonPretty::print([
    'store' => 'Best Buy',
    'number' => 30305,
    'products' => [
        [
            'name' => 'TV',
            'cost' => 2000.00,
            'in_stock' => true
        ],
        [
            'name' => 'Phone',
            'cost' => 350.80,
            'in_stock' => false
        ],
        [
            'name' => 'Sample',
            'cost' => 0,
            'in_stock' => null
        ]
    ]
]);
```

The previous snippet will return the following string:

[![Print output](https://raw.githubusercontent.com/rcubitto/json-pretty/master/print-example-one.png?token=AARLMXW34PBRSGY4GRCWHGS6PWVZ2)](https://raw.githubusercontent.com/rcubitto/json-pretty/master/print-example-one.png?token=AARLMXW34PBRSGY4GRCWHGS6PWVZ2)

You can also print an object class:

```
$obj = new \Stdclass;
$obj->prop = 1;
$obj->another = 2;

\Rcubitto\JsonPretty\JsonPretty::print($obj);
```

Output:

[![Print output](https://raw.githubusercontent.com/rcubitto/json-pretty/master/print-example-two.png?token=AARLMXXFQXV6NZ3DO5XC2UC6PWWOA)](https://raw.githubusercontent.com/rcubitto/json-pretty/master/print-example-two.png?token=AARLMXXFQXV6NZ3DO5XC2UC6PWWOA)

**NOTE**: the string is not echoed out, just returned. So if you want to actually echo it out, don't forget to do so.

Config
------

[](#config)

You can also configure different colors for different types.

```
$options = [
    'colors' => [
        'bracket' => 'blue',    // {}[] and object keys
        'number' => 'green',    // any is_numeric (except strings like "1")
        'string' => 'purple',
        'boolean' => 'pink',
        'null' => 'black'
    ]
];

\Rcubitto\JsonPretty\JsonPretty::print($sample, $options);
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please use the issue tracker.

Credits
-------

[](#credits)

- [Raúl Cubitto](https://github.com/rcubitto)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

PHP Package Boilerplate
-----------------------

[](#php-package-boilerplate)

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~65 days

Recently: every ~97 days

Total

7

Last Release

1905d ago

Major Versions

0.1.5 → 1.02021-04-15

PHP version history (2 changes)0.1PHP ^7.1

1.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2274910?v=4)[raul](/maintainers/rcubitto)[@rcubitto](https://github.com/rcubitto)

---

Top Contributors

[![rcubitto](https://avatars.githubusercontent.com/u/2274910?v=4)](https://github.com/rcubitto "rcubitto (8 commits)")[![roberto-aguilar](https://avatars.githubusercontent.com/u/5356595?v=4)](https://github.com/roberto-aguilar "roberto-aguilar (2 commits)")

---

Tags

jsonlaravelphppretty-printrcubittojson-pretty

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rcubitto-json-pretty/health.svg)

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

###  Alternatives

[dlds/yii2-metronic

Yii2 Metronic theme integration

4614.1k1](/packages/dlds-yii2-metronic)

PHPackages © 2026

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