jq command
Read, filter and reshape JSON on the command line.
- Text processing
- Package jq
- 8 options · 9 examples
Syntax
jq [options] filter [file…]Provided by the jq package. Run man jq for the full manual.
Common options
| Option | What it does |
|---|---|
. | The whole input, pretty-printed |
.key | A field |
.[] | Every array element |
-r | Raw strings without quotes |
-c | Compact output, one line |
select(COND) | Keep items that match |
-s | Read all inputs into one array |
--arg NAME VAL | Pass a variable |
Examples
Pretty-print JSON
jq . data.jsonGet a field
jq .name package.jsonRaw string without quotes
jq -r .version package.jsonEvery element of an array
jq '.[]' items.jsonOne field from each element
jq -r '.[].name' users.jsonFilter items
jq '.[] | select(.age > 30)' users.jsonCount items
jq length items.jsonFrom an API
curl -s https://api.github.com/repos/jqlang/jq | jq '.stargazers_count'Build new objects
jq '.[] | {id, email}' users.json
No example matches. Check the options table or search the guides.
jq guides
- JQ Command in Linux with Examples Linux Commands · Updated Apr 2025
- Top 10 JQ Commands Every Linux Developer Should Know Linux Commands · Updated Apr 2025
