jq JSON CLI
Updated 2026-02-15
jq for filtering and transforming JSON in the shell. Select fields, slice arrays, and format output.
Select and filter
echo '{"a":1}' | jq .aGet field.
jq '.items[]' file.jsonArray iteration.
jq '.users[] | select(.age > 18)' file.jsonFilter objects.
jq '.key // "default"' file.jsonDefault value.
Transform and build
jq -s 'add' file.jsonSlurp and add (e.g. numbers).
jq '[.items[].name]' file.jsonBuild array of values.
jq '{key: .field}' file.jsonBuild object.
jq -r '.name'Raw output (no quotes).