Pretty printing JSON output in terminal

If you need to pretty print the json output of a terminal command (so you can inspect it more easily), you can use python's json module. I usually use it to pretty print the output of curl command. Here is an example

    :::bash
    curl http://somesite.com/my/json/ | python -m json.tool

This utility can also be used to pretty print json files like following

    :::bash
    python -m json.tool minified.json > prettyprint.json

blog comments powered by Disqus