Pretty-Printing JSON with Python’s JSON Tool

Today’s quick tip is something that was widely retweeted after my “Debugging HTTP” talk at the ever-fabulous WhiskyWeb conference last weekend. When working with JSON on the commandline, here’s a quick tip for showing the JSON in a nicer format:

curl http://api.joind.in | python -mjson.tool

You need python installed, but the JSON extension is probably included, and that’s all you need for this tool. The result is something like:

python-mjsontool

You can also use this approach to present JSON data that has been captured to another file, for example, it’s a handy trick that I use often when developing something with JSON as a data format.

6 thoughts on “Pretty-Printing JSON with Python’s JSON Tool

  1. 7 year glitch! I just stumbled across this post when searching something like ‘lorna http tools’ to recap on your stimulatingly super presentation at the virtual Python North West Meetup yesterday! Still a great tool 7 years later, and history repeated itself when HTTPIE got mentioned too.

    I just deployed my blog today also, I wonder what it will look like 7 years from now? I hope as great as yours does now.

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.