Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 661 Bytes

pretty-print-curl-json.md

File metadata and controls

20 lines (13 loc) · 661 Bytes

Pretty print JSON returned via Curl

When curling API endpoints and you get a large JSON payload it can be difficult to examine it without either copying and pasting to an editor or grepping. Using this handy little Python utility will pretty print any returned JSON.

curl -v https://someapi-we-want-to-use | python -m json.tool

If you'd like to colourize the JSON output then you can achieve this with:

curl -v https://someapi-we-want-to-use | python -m json.tool | pygmentize -l json

However for the easiest time, add it all as an alias in bash_aliases

alias prettyjson='python -m json.tool | pygmentize -l json'