yruktg
Last Updated: February 25, 2016
·
3.076K
· 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

6653

It just works! Thanks!

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

over 1 year ago ·
10682

@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

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

over 1 year ago ·