yruktg
Last Updated: February 25, 2016
·
1.631K
· barnettjw
43ea08b4fc547e8a5da87c207bea2123

Pretty Print JSON in the Terminal

Working with JSON on command line can be tough to read, use this Python one-liner, to clean it up.

cat json | python -mjson.tool
Say Thanks
Respond

3 Responses
Add your response

6653

It just works! Thanks!

BTW, do you know such a neat one-liner which also adds syntax highlighting?

over 1 year ago ·
10682
06cc2c32ff31c62aa34917d2b046784d

@antonov, I tried:
alias jsonpp='cat $1 | python -mjson.tool | pygmentize -l'
but the python have problem getting the piped input.

So I used a function:
function jsonpp () { cat "$@" | python -mjson.tool | pygmentize -l json }

over 1 year ago ·
17890
3d17f7b

Assuming the JSON is already un-minified, you can just use pygmentize -g file.json

over 1 year ago ·
Filed Under