Last Updated: February 25, 2016
·
1.182K
· mrallen1

Pretty print JSON from the command line using python

Python's out of the box JSON library is pretty badass although I tend to use simplejson in my code.

One of the coolest things about it is the JSON tool, which you can invoke easily using the -m option in python.

For example, if you wanted to query a REST endpoint and pretty print the result, you can use something like

curl -s http://example.com/api/v1/frobulate | python -mjson.tool