Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Readable output from JSON.stringify
var o = {hello:'world', greetings: ['one', 'two', 'three']};
undefined
// regular, difficult to read for large objects
JSON.stringify(o);
"{"hello":"world","greetings":["one","two","three"]}"
// presto!
JSON.stringify(o, '', ' ');
"{
"hello": "world",
"greetings": [
"one",
"two",
"three"
]
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment