1pcc_g
Last Updated: February 25, 2016
·
887
· ultimatedelman

Pretty-Print JSON Using JSON.stringify()

Did you know that JSON.stringify() takes additional parameters?

JSON.stringify(myObj, null, 4);

This will pretty-print your stringified JSON object using 4 spaces for indentation. The second parameter is a "replacer" param that determines what is kept or removed from the final string.

Demo