How to Pretty Print cURL JSON Output in Terminal

In order to pretty print the cURL output which is in JSON format you can make use of the Python json module.


% curl -s | python3 -m json.tool

    "results": [
            "gender": "male",
            "name": {
                "title": "Mr",
                "first": "Akhil",
                "last": "Rai"
            "location": {
                "street": {
                    "number": 7324,
                    "name": "Coaker's Walk"
                "city": "Thrissur",
                "state": "Rajasthan",
                "country": "India",
                "postcode": 41746,
                "coordinates": {
                    "latitude": "8.2937",
                    "longitude": "-5.5920"
                "timezone": {
                    "offset": "-6:00",
                    "description": "Central Time (US & Canada), Mexico City"
            } ...

Pretty Print cURL JSON Output using Python json tool

This does format the JSON output but does not add color coding, for this, you can download packages from Brew such as jsonpp or jq


% brew install jq
% curl -s | jq
cURL JSON Output Pretty Printed with Colors

Have Questions? Post them here!