| name | jq |
| description | Command-line JSON processor. Extract, filter, transform JSON. |
jq
Command-line JSON processor for extracting, filtering, and transforming JSON.
Installation
macOS / Linux (Homebrew):
brew install jq
All platforms: See jqlang.org/download for packages, binaries, and build instructions.
Usage
jq '[filter]' [file.json]
cat file.json | jq '[filter]'
Quick Reference
.key
.a.b.c
.[0]
.[]
.[] | select(.x > 5)
{a: .x, b: .y}
. + {new: "val"}
del(.key)
length
[.[] | .x] | add
keys
unique
group_by(.x)
Flags
-r raw output (no quotes) · -c compact · -s slurp into array · -S sort keys
Examples
jq '.users[].email' data.json
jq -r '.name // "default"' data.json
jq '.[] | select(.active)' data.json
jq -s 'add' *.json
jq '.' file.json