Main Tutorials

How to Pretty Print JSON output in cURL

In cURL requests, the default JSON output is in compact format.

Terminal

curl https://api.cloudflare.com/client/v4/

{"success":false,"errors":[{"code":7000,"message":"No route for that URI"}],"messages":[],"result":null}

In cURL, we can use or pipe the json_pp to pretty print the JSON output.

Terminal

curl https://api.cloudflare.com/client/v4/ | json_pp

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   104    0   104    0     0    400      0 --:--:-- --:--:-- --:--:--   398
{
   "errors" : [
      {
         "code" : 7000,
         "message" : "No route for that URI"
      }
   ],
   "success" : false,
   "result" : null,
   "messages" : []
}

References

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
5 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Bob
2 years ago

Well, you made my day. I have been playing around with Python modules to do this because I did not know about json_pp. Thanks so much sir. Have a great day.

B

Nabil
1 year ago

json_pp for the win. Thanks mkyong.

tottran
9 days ago

Thank you Mkyong!

Abdal Asif
10 months ago

Thanks mkyong