Manipulating JSON with jq

Learn how to manipulate JSON with jq.

Setting up jq

The jq command-line program lets us format and manipulate JSON data. It’s perfect when exploring APIs from the command line. We provide jq with some JSON data to process and a filter to apply. It transforms the JSON data and displays the results.

We install jq from the package manager. On Ubuntu, we use apt:

sudo apt install jq

On macOS, we use brew:

brew install jq

One of the most common uses is to pretty print JSON results from curl.

Open Notify has several free APIs we can query to find information about the International Space Station (ISS). If we use curl to request data from this endpoint, which displays the current location of the ISS, the output might not be very readable:

curl http://api.open-notify.org/iss-now.json

Use the terminal below to practice this command.

Get hands-on with 1200+ tech skills courses.