From http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script.
From the command line, python -mjson.tool
is easy.
$ echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool
In JavaScript, you can add an indentation level to the third argument of JSON.stringify ()
.
JSON.stringify({ foo: "lorem", bar: "ipsum" }, null, 4);