Last Updated: February 25, 2016
·
4.308K
· barnettjw

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

3 Responses
Add your response

It just works! Thanks!

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

over 1 year ago ·

@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 ·

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

over 1 year ago ·