To use it you just can write :
var jsonFormattedString = JSON.stringify(json, null, 2); // spacing level = 2
And that's it ! You will get a nicely formatted json.
In case you would like also to add some colors to your formatted json, you can use this snippet :