PHPackages                             deftek/json\_pp - 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. deftek/json\_pp

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

deftek/json\_pp
===============

JSON Pretty Printer

1.0.0(8y ago)382593BSD-3-ClausePHPPHP &gt;=5.5.0

Since Jul 15Pushed 8y agoCompare

[ Source](https://github.com/deftek/json_pp)[ Packagist](https://packagist.org/packages/deftek/json_pp)[ Docs](https://github.com/deftek/json_pp)[ RSS](/packages/deftek-json-pp/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

json\_pp - JSON Pretty Printer
==============================

[](#json_pp---json-pretty-printer)

The `json_pp` utility prints [JSON](http://www.json.org/) data in a legible, indented format. It provides the most benefit to people who need to read, inspect, and understand JSON data structures that are not already provided with separating white space, such as software developers building or consuming JSON-based APIs.

By default, `json_pp` does not escape slashes or multi-byte Unicode characters. These characters may be escaped by overriding the default encode options with a configuration file. Pretty-printing may be similarly disabled when compact JSON is needed and the source JSON is already formatted with white space.

System Requirements
-------------------

[](#system-requirements)

- [PHP](http://php.net/) 5.5.0 or later must be available at the command line in order to run `json_pp`. Users of older versions of PHP [should seriously consider upgrading](http://php.net/eol.php). PHP 7 or later is required to run the test suite.
- [Composer](https://getcomposer.org/) is used for automating installation, and it is also possible to manually download and install this package.

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

[](#installation)

To make `json_pp` available to all system users, which may require system administrator (e.g., root) privileges:

```
composer global install deftek/json_pp

```

To make `json_pp` available only for the current system user:

```
composer install deftek/json_pp

```

To include `json_pp` in a project that uses Composer:

```
composer require deftek/json_pp

```

To include `json_pp` for development purposes in a project that uses Composer:

```
composer require --dev deftek/json_pp

```

Usage
-----

[](#usage)

### Pretty-print compact JSON contained in a string

[](#pretty-print-compact-json-contained-in-a-string)

```
echo '{"foo":{"bar":"baz"}}' | json_pp

```

Output:

```
{
    "foo": {
        "bar": "baz"
    }
}

```

### Pretty-print compact JSON contained in a file:

[](#pretty-print-compact-json-contained-in-a-file)

```
json_pp < compact.json

```

### Output compact JSON from pretty-printed source:

[](#output-compact-json-from-pretty-printed-source)

```
echo pretty.json | json_pp --config=config.compact.php

```

Where `config.compact.php` contains something like:

```
