echo json in php formated

PHP
<?php
...
$json_string = json_encode($data, JSON_PRETTY_PRINT);
Source

Also in PHP: