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
Key Facts
- jq is a lightweight and flexible command-line JSON processor.
- It was first released in 2012.
- jq is available for Linux, macOS, and Windows.
- It allows you to slice, filter, map, and transform structured data with ease.
- Over 10,000 GitHub stars indicate its popularity and widespread use.
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:
- Extract specific fields: Get only the values you're interested in.
- Filter data: Select objects or arrays based on certain conditions.
- Transform data: Reshape JSON into a different structure.
- Pretty-print JSON: Make JSON output more readable.
- Perform calculations: Aggregate or compute values from JSON data.
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 jqLinux (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 jqmacOS
If you are using macOS, the easiest way to install jq is with Homebrew, a popular package manager for macOS:
brew install jqIf 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:
- Using Chocolatey: If you use the Chocolatey package manager, you can install
jqwith a simple command:choco install jq - Downloading Binaries: You can download pre-compiled binaries directly from the
jqreleases page on GitHub. Look for the appropriate.exefile for your system architecture (32-bit or 64-bit) and place it in a directory that is included in your system's PATH environment variable.
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 installEnsure 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 --versionThis 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": "alice@example.com"},{"name": "Bob", "email": "bob@example.com"}]}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.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
Missing an answer?
Suggest a question and we'll generate an answer for it.