Best json beautifier

Friday 14th, Sep, 2018 | #Ajax

Free resourses to convert your minified JSON code into human readable and understandable format.

Json is an open-source file format that uses human-readable text to transmit data objects that consist of pairs of value-attributes and array data types (or any other serializable value). It is a very common data format used for asynchronous communication between browser-server, which is offered as a replacement for the well-known XML in some systems.

Format JSON With a PHP Function

function beautifier($json) {

    $result      = '';
    $pos         = 0;
    $strLen      = strlen($json);
    $indentStr   = '  ';
    $newLine     = "\n";
    $prevChar    = '';
    $outOfQuotes = true;

    for ($i=0; $i<=$strLen; $i++) {

        // Grab the next character in the string.
        $char = substr($json, $i, 1);

        // Are we inside a quoted string?
        if ($char == '"' && $prevChar != '\\') {
            $outOfQuotes = !$outOfQuotes;

        // If this character is the end of an element,
        // output a new line and indent the next line.
        } else if(($char == '}' || $char == ']') && $outOfQuotes) {
            $result .= $newLine;
            $pos --;
            for ($j=0; $j<$pos; $j++) {
                $result .= $indentStr;

        // Add the character to the result string.
        $result .= $char;

        // If the last character was the beginning of an element,
        // output a new line and indent the next line.
        if (($char == ',' || $char == '{' || $char == '[') && $outOfQuotes) {
            $result .= $newLine;
            if ($char == '{' || $char == '[') {
                $pos ++;

            for ($j = 0; $j < $pos; $j++) {
                $result .= $indentStr;

        $prevChar = $char;

    return $result;

Now if you do not want to program or simply have to do it fast, you have some online tools that can be useful for you

JSONLint - The JSON Validator

JSONLint is the free online validator and reformatter tool for JSON, a lightweight data-interchange format.

JSON Editor Online - view, edit and format JSON online

JSON Editor Online is a web-based tool to view, edit, and format JSON. It shows your data side by side in a clear, editable treeview and in a code editor.

JSON Beautifier Online - Convert Town

JSON Beautifier - Online in-browser tool. ... This tool formats and beautify's your JSON text inside your browser. © 2018.

JSONMate - JSON editor, inspector and beautifier

Edit your JSON directly in the textarea above. The JSON editor will get updated when you leave the field.

JSON Formatter - Chrome Web Store - Google

Makes JSON easy to read. Open source. A fork of the original (no-longer updated) extension by Callum Locke. FEATURES • JSON & JSONP.