9951 explained code solutions for 126 technologies


javascriptPretty print JSON


var obj = {a: 1, b: 2};
console.log( JSON.stringify(obj, null, 2) );ctrl + c
var obj

declare test object to print

JSON.stringify

convert JSON to string (docs)

, 2)

will format JSON with 2-spaces indents