Couple dozen other ways to do it: <a href="http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script/5006476" rel="nofollow">http://stackoverflow.com/questions/352098/how-to-pretty-prin...</a>
A problem with piping curl output through "python -mjson.tool" is that you can't include the response headers, which is sometimes useful.<p>(This was enough of a problem for me that I wrote a simple curl replacement in Python so I could have pretty-printed JSON or XML <i>and</i> response headers, <i>or</i> send the response directly to a Python REPL console as an object: <a href="https://github.com/cobralibre/hotpotato" rel="nofollow">https://github.com/cobralibre/hotpotato</a> )
Here is Paul Irish's .function dotfile solution: <a href="https://github.com/paulirish/dotfiles/blob/master/.functions#L55" rel="nofollow">https://github.com/paulirish/dotfiles/blob/master/.functions...</a>.<p>Really recommend setting up his dotfiles. After you back up your dotfiles, you can install his (which overwrites yours) just by writing<p><pre><code> git clone https://github.com/paulirish/dotfiles.git && cd dotfiles && ./sync.sh</code></pre>
Here is the bash alias I have been using for CLI JSON formatting, and as a bonus, my random password generator:<p>alias jsonpp='ruby -r json -e '\''puts JSON.pretty_generate(JSON.parse(STDIN.read))'\'''<p>alias md5pass='dd if=/dev/random bs=100 count=1 2>/dev/null | md5'
I've done something similar a while back. A simple "works-for-me" package. Feel free to try it out:<p><a href="https://github.com/exhuma/braindump/tree/master/jsonformat" rel="nofollow">https://github.com/exhuma/braindump/tree/master/jsonformat</a>
httpie is a nice replacement for curl which, among other things, has built-in formatting so you can get pretty JSON / XML responses without giving up your ability to do things like displaying response headers:<p><a href="https://github.com/jkbr/httpie" rel="nofollow">https://github.com/jkbr/httpie</a>