jq is the standard command-line JSON processor for Linux—think grep/awk, but for structured data. You pipe API responses, log lines, and config files through jq filters to pretty-print, extract fields, filter arrays, and reshape output for scripts. On Ubuntu, jq lives in the main repository as a normal apt package (available since Ubuntu 16.04+ per Stack Overflow); you do not need to edit sources.list on current LTS releases.
This guide shows how to install jq on Ubuntu, verify the binary, run practical examples with files and cURL, fix Unable to locate package jq, and optionally install a newer build from jqlang/jq releases. I ran the commands on Ubuntu 25.04 and kept real output below.
Tested on: Ubuntu 25.04 (Plucky Puffin); kernel 6.14.0-37-generic; jq 1.7.1 (
jq --versionprintsjq-1.7).
sudo apt update before apt install jq. Stack Overflow and Lindevs both treat that as step one—without it apt may suggest Snap or report the package missing even though jq exists in the archive.
Quick command summary
| Task | Command |
|---|---|
| Refresh indexes | sudo apt update |
| Install (recommended) | sudo apt install -y jq |
| Check candidate | apt-cache policy jq |
| Verify | jq --version and which jq |
| Pretty-print | jq . file.json or echo '{"a":1}' | jq . |
| Extract a field | jq '.data[0].name' file.json |
| With curl | curl -fsS URL | jq . |
| Remove | sudo apt purge -y jq |
Choose an install path
| Method | Best for | Jump to |
|---|---|---|
apt (jq) |
Everyday use, security updates, scripts | Install from apt |
Local .deb |
Offline install or pinning an exact Ubuntu build | Install a downloaded .deb |
| GitHub release binary | Newer upstream jq (1.8.x) without compiling | Upstream binary |
| Build from source | Custom builds, no root (user prefix) | Build from source |
For most readers, sudo apt install jq is enough.
Prerequisites
- Ubuntu 22.04 LTS, 24.04 LTS, or newer (25.04 tested here) on amd64 or arm64.
- sudo for apt installs.
- Working apt repositories (
mainat minimum). - For API examples: cURL and outbound HTTPS.
What you are installing
| Package | Role |
|---|---|
jq |
CLI binary at /usr/bin/jq |
libjq1 |
Shared library the jq command links against |
libonig5 |
Oniguruma regex engine used by jq filters |
sudo apt install jq pulls dependencies automatically—you do not install libjq1 separately for normal CLI use.
Install jq from apt (recommended)
Refresh package lists and inspect the candidate:
sudo apt update
apt-cache policy jqOn Ubuntu 25.04:
jq:
Installed: (none)
Candidate: 1.7.1-3ubuntu1.1
Version table:
1.7.1-3ubuntu1.1 500
500 http://archive.ubuntu.com/ubuntu plucky-updates/main amd64 PackagesInstall:
sudo apt install -y jqVerify:
jq --version
which jq
command -v jqjq-1.7
/usr/bin/jq
/usr/bin/jqThe Debian version is 1.7.1; jq --version abbreviates it as jq-1.7. You also get man jq under /usr/share/man/man1/jq.1.gz.
First use: pretty-print and filter JSON
Pretty-print inline JSON
The . filter is the identity operator—it reformats JSON without changing values (jqlang.org):
echo '{ "name":"John", "age":31, "city":"New York" }' | jq .{
"name": "John",
"age": 31,
"city": "New York"
}Read from a file and extract fields
echo '{"status":"success","data":[{"name":"John","age":25},{"name":"James","age":29}]}' > /tmp/example.json
jq '.' /tmp/example.json
jq '.data[1].name' /tmp/example.jsonSecond command output:
"James"Combine with curl
curl -fsS https://httpbin.org/get | jq '.headers.Host'"httpbin.org"Use jq '.headers' to dump the whole headers object, or jq -c for compact single-line output in scripts.
Optional: install a local .deb
When you need an exact Ubuntu package file (air-gapped host or version pin), download the .deb for your release from packages.ubuntu.com and install locally:
sudo apt install ./jq_1.7.1-3ubuntu1.1_amd64.debapt install ./file.deb resolves dependencies from your configured repositories—prefer this over raw dpkg -i when the network is available.
Optional: install jq from GitHub releases
Ubuntu apt may lag the latest jq release ( 1.8.2 at the time of writing). For a standalone binary without compiling:
mkdir -p ~/.local/bin
curl -fsSL -o ~/.local/bin/jq \
https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-amd64
chmod +x ~/.local/bin/jq
export PATH="$HOME/.local/bin:$PATH"
jq --versionjq-1.8.2On arm64, use jq-linux-arm64 instead of jq-linux-amd64. Add export PATH="$HOME/.local/bin:$PATH" to ~/.bashrc if you want the binary in every shell.
~/.local/bin/jq can shadow /usr/bin/jq when your PATH lists ~/.local/bin first. Know which binary you are running: type -a jq.
Optional: build jq from source
Follow the jqlang/jq README when you need a custom build or cannot use apt. On Ubuntu, install build dependencies first:
sudo apt install -y autoconf automake libtool make gcc git
git clone https://github.com/jqlang/jq.git
cd jq
git submodule update --init
autoreconf -i
./configure --with-oniguruma=builtin --prefix="$HOME/.local"
make -j"$(nproc)"
make check
make installUse --prefix="$HOME/.local" when you lack sudo—same pattern as no-root jq builds discussed on Stack Overflow.
Uninstall jq
Apt install:
sudo apt purge -y jq
sudo apt autoremove -ySee remove unused packages on Ubuntu if apt reports orphaned libraries after purge.
Manual GitHub binary:
rm -f ~/.local/bin/jqTroubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Unable to locate package jq |
Stale apt indexes | sudo apt update, then retry install |
apt suggests snap install jq |
Indexes empty or minimal image | Run apt update; prefer apt jq over Snap for /usr/bin/jq |
jq: command not found |
Not installed or PATH | sudo apt install jq or add ~/.local/bin to PATH |
parse error: Invalid numeric literal |
Input is not JSON | Validate with jq . on a file; check for HTML error pages from curl |
Cannot index array with string |
Wrong filter for JSON shape | Inspect structure first: jq 'type' or jq 'keys' |
Two different jq --version values |
Multiple installs on PATH | type -a jq; remove duplicate or adjust PATH order |
| Need jq 1.8+ features | Ubuntu ships 1.7.x | Use GitHub release binary |
References
- jqlang/jq — GitHub (source, releases, documentation)
- jq manual and jq playground
- Install jq on Ubuntu — Stack Overflow
- Lindevs — install jq on Ubuntu
- Install cURL on Ubuntu
Summary
Installing jq on Ubuntu is usually two commands: sudo apt update and sudo apt install -y jq. Verify with jq --version, pretty-print with jq ., and drill into APIs using curl … | jq 'filter'. If apt cannot see the package yet, update indexes before chasing Snap or third-party repos. Reach for a jqlang/jq release binary only when you need features in a newer upstream version than your Ubuntu archive ships.

