Last Updated: February 25, 2016
·
1.887K
· lizell

Pretty print JSON in your terminal

Sometimes you have the need to pretty print some JSON you are looking at in your terminal. Much like what xmllint --format does for XML.

With python around it is very easy. Just use python -mjson.tool:

echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool

outputs:

{
    "bar": "ipsum",
    "foo": "lorem"
}