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
Written by James Barnett
Related protips
3 Responses
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#