Pretty print Curl JSON responses in terminal

Today I wanted to test one of my APIs and used curl to get the response in the terminal. The output wasn't clear at all because it usually returns everything in one line. 

 

Fortunately, there was a way to pretty-print the response, as in real json format. All you have to do is pipe the json_pp command after your curl command.

 

Ex: 


curl --location --request GET 'http://my.api.local/api' --header '...' | json_pp

 

and that's it. You should see a formatted json response.

 

Pretty print Curl JSON responses

Hope this will help someone. Please feel free to comment and let me know if you know any other better way :)

7 comments :

  1. Checkout our website for buying guide about gas stoves.
    Hob top gas stove

    ReplyDelete
  2. Checkout our website for buying guide about gas stoves.
    Hob top gas stove

    ReplyDelete
  3. https://bitmapcake.blogspot.com/2021/01/pretty-print-curl-json-responses-in.html?showComment=1613556698797#c2399693857365168803

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thanks for sharing this amazing and informative post. keep sharing with us.

    ReplyDelete