Unpretty print a JSON file

I needed a one-liner JSON payload, but only had the pretty-printed version. And, removing the whitespaces manually was NOT an option. It was super easy on a Mac; just do the following:

    1. In a terminal, install “jq” with brew like so

brew install jq

    1. With your pretty-printed JSON in a file:

cat prettyprinted.json | jq -c .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.