Last Updated: February 25, 2016
·
591
· whaley

Pretty Print any JSON from the CLI

Using python, either pipe in json or pass in a filename to

python -mjson.tool

For instance

% cat foo.json                                            
{"something":"needs formatting","really badly":1}
 % cat foo.json | python -mjson.tool                         
{
    "really badly": 1, 
    "something": "needs formatting"
}
 % python -mjson.tool foo.json                               
{
    "really badly": 1, 
    "something": "needs formatting"
}