I took his script, made a few modifications, converted it into a jQuery Plugin, and published it to GitHub (https://github.com/MHeironimus/jsonFormatter). To use this plugin include jsonFormatter.min.css and jsonFormatter.min.js in your html file. See the jsonFormatterExample.html file for an example on how to do this. If you wish to use the darkTheme, include the jsonFormatter-darkTheme.min.css file.
An example webpage that uses the jsonFormatter jQuery Plugin can be viewed at https://static.heironimus.info/blog/jsonformatter/example/jsonFormatterExample.html.
Description: If the matched elements contain JSON, they are formatted to be easier to read. Arrays and object are optionally collapsible.
Specifies if object’s keys should be quoted in the formatted output.
Specifies if arrays and objects are collapsible in the formatted output.
Specifies if the original element is hidden. The element will only be hidden if it contains valid JSON that was successfully formatted.