JSON.format(json) Last updated: 30. May 2026

Outputs specified JSON string to "prettified" indented JSON.

Parameters

Name Type Description
json string

JSON string to format.

Returns

The formatted JSON string.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    var object = {
        "Name" : "Abcd",
        "Number" : 1234
    };
    
    // Convert object to JSON string
    var json  = JSON.stringify(object);
    
    // Format indent and line breaks in JSON
    var pretty = JSON.format(json);
    
    // Remove empty lines
    var html = pretty.replace(chr(13), "");
    
    // Write HTML to output
    write(html);
}#

Output

The #JS code above produces the output shown below:
{
  "Name": "Abcd",
  "Number": 1234
}