Pretty-printing JSON in the Terminal

I use cURL quite a bit when debugging APIs and I found this neat trick for pretty-printing JSON output. Add the following line to your .bashrc or .zshrc file,

alias json="python -m json.tool"

Then you can pipe your cURL output through your new json tool and print everything nicely,

curl -g http://some.domain/api/call | json

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.