Curl, JSON and Pretty Print

Curl is a wonderful thing. The output can be a bit messy, however.

This python pipe pretty prints your otherwise messy JSON output.

$ curl -H 'Accept: application/json' http://localhost:3001/myserver/cmd | python -mjson.tool

Or, using Ruby, if necessary run

sudo gem install json

then pipe your output.

cat myfile.json | prettify_json.rb

An even nicer solution is this node script, written specifically to handle curl output. You’ll need to make sure you’ve installed Node.js before you can use it.