JQ | JSON in the terminal...?

Published: Thu, Jun 19, 2025

JSON in a terminal? Why not! Today, Vincent talks about a command that's pretty new to him: jq. JQ lets you read and write JSON data right in the shell.

Links:

Video Notes

Below are some simple examples to get you started. I find JQ isn’t too bad to learn, but I’m sure an example or two couldn’t hurt, right?

JQ Examples

Our JSON Data:

[{
	"name": "Vincent"
},
{
	"name": "Sally"
}]

Installing JQ

Getting started with JQ is easy, just follow the example below. But first, to install it, run the apt command below, if you’re using Debian.

sudo apt install jq -y

Simple Example

echo '[{"name": "Vincent"},{"name": "Sally"}]' | jq .

Now this will pretty-print the JSON output for us, including code highlighting and indentation. To see how to make practical use of the data, check out the next example below.

Practical Use

name=$(echo '[{"name": "Vincent"},{"name": "Sally"}]' | jq .[][0].name)

In the above command, 0 is the array index, and .name gets us the person’s name. All of this is then stored in a variable called name (since I don’t make fancy names).