JavaScript Tip: JSON.stringify with pretty print

If you want to get a string representation of a JavaScript object, you can do JSON.stringify. We all know that :-)

But sometimes we save this object to a file, so humans can read it. 
In those scenarios, it’s nice to be able to insert some whitespace/indentation so the damn thing is readable and editable by humans.

Just substitute,

JSON.stringify(object) 

with

JSON.stringify(object, null, 2);

And you have pretty print! BAM!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.