jq

A lightweight and flexible command-line JSON processor.

Install

All systems
curl cmd.cat/jq.sh
Debian Debian
apt-get install jq
Ubuntu
apt-get install jq
Alpine
apk add jq
Arch Arch Linux
pacman -S jq
image/svg+xml Kali Linux
apt-get install jq
Fedora
dnf install jq
OS X
brew install jq
Raspbian
apt-get install jq
Docker
docker run cmd.cat/jq jq powered by Commando

A lightweight and flexible command-line JSON processor.

  • Output a JSON file, in pretty-print format:
    jq . file.json
  • Output all elements from arrays (or all key-value pairs from objects) in a JSON file:
    jq .[] file.json
  • Read JSON objects from a file into an array, and output it (inverse of `jq .[]`):
    jq --slurp . file.json
  • Output the first element in a JSON file:
    jq .[0] file.json
  • Output the value of a given key of the first element in a JSON text from stdin:
    cat file.json | jq .[0].key_name
  • Output the value of a given key of each element in a JSON text from stdin:
    cat file.json | jq 'map(.key_name)'

© tl;dr; authors and contributors