In order to pretty print the cURL output which is in JSON format you can make use of the Python json module.
Example:
% curl -s https://randomuser.me/api/ | 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"
}
} ...

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
Example:
% brew install jq

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!