Python: pretty print json
Nov 09, 2015
devtip , python
Original source: http://stackoverflow.com/questions/352098/how-can-i-pretty-print-json
With Python 2.6+
echo '{"foo": "lorem", "bar": "ipsum"}' | python -m json.tool
Or if the json data is in file:
cat <data_file> | python -m json.tool
Handly shell alias:
alias prettyjson='python -m json.tool'