How to install jq

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: To install `jq`, you can use your system's package manager (like `apt`, `yum`, `brew`, or `dnf`) or download a pre-compiled binary from the official `jq` website. The installation process is straightforward and typically takes only a few moments.

Key Facts

What is jq?

jq is a powerful, lightweight, and flexible command-line JSON processor. Think of it as `sed` for JSON data. It allows you to easily slice, filter, map, and transform structured data with its expressive query language. Whether you're working with APIs, configuration files, or log files, jq can help you extract and manipulate the information you need directly from your terminal.

Why Use jq?

In today's data-driven world, JSON (JavaScript Object Notation) is a ubiquitous format for data interchange. When dealing with JSON data on the command line, simply printing it can be overwhelming, especially for large or deeply nested structures. jq provides a way to:

This makes it an indispensable tool for developers, system administrators, and anyone who frequently interacts with JSON data in a command-line environment.

How to Install jq

The installation method for jq depends on your operating system and preferred package manager.

Linux (Debian/Ubuntu)

On Debian-based systems like Ubuntu, you can install jq using the Advanced Packaging Tool (APT):

sudo apt updatesudo apt install jq

Linux (Fedora/CentOS/RHEL)

For Fedora or systems using RPM Package Manager (like CentOS and RHEL), you can use dnf or yum:

# Using dnf (Fedora 22+)sudo dnf install jq# Using yum (Older Fedora, CentOS, RHEL)sudo yum install jq

macOS

If you are using macOS, the easiest way to install jq is with Homebrew, a popular package manager for macOS:

brew install jq

If you don't have Homebrew installed, you can find instructions on their official website: https://brew.sh/.

Windows

For Windows users, there are a couple of options:

From Source

For advanced users or if you need the latest development version, you can compile jq from its source code. This typically involves downloading the source, installing build dependencies (like a C compiler and `make`), and then running the standard build process:

git clone https://github.com/jqlang/jq.gitcd jqautoreconf -fi./configuremakesudo make install

Ensure you have the necessary build tools installed on your system before attempting to compile from source.

Verifying the Installation

After installation, you can verify that jq is installed correctly by checking its version:

jq --version

This command should output the installed version number of jq. If you encounter errors, double-check that jq was installed to a location included in your system's PATH.

Basic Usage Example

Let's say you have a JSON file named data.json with the following content:

{"name": "Example Project","version": "1.0.0","dependencies": {"react": "^17.0.2","lodash": "4.17.21"},"contributors": [{"name": "Alice", "email": "[email protected]"},{"name": "Bob", "email": "[email protected]"}]}

To extract the project name, you would use:

cat data.json | jq '.name'

Output:

"Example Project"

To extract the names of all contributors:

cat data.json | jq '.contributors[].name'

Output:

"Alice""Bob"

jq is an incredibly versatile tool, and mastering its query language can significantly boost your productivity when working with JSON data.

Sources

  1. jq - Lightweight and flexible command-line JSON processorMIT
  2. jq Tutorialfair-use
  3. Homebrew: The missing package manager for macOSBSD-3-Clause

Missing an answer?

Suggest a question and we'll generate an answer for it.