Command-line JSON processor and transformer.
low risk
jq is a lightweight, flexible JSON processor. It slices, filters, transforms, and reformats JSON data with a pipeline syntax. Essential for working with API responses, Kubernetes output, and cloud CLI tools that return JSON.
| Flag | Meaning |
|---|---|
-r --raw-output | Output raw strings without JSON quotes |
-c --compact-output | Compact output on one line |
-s --slurp | Read all input into an array |
-e --exit-status | Return exit code 1 if result is false/null |
kubectl get pods -o json | jq '.items[].metadata.name'Extract all pod names · explain & risk-check →curl -s api.example.com/data | jq '.results[] | select(.status=="active")'Filter active items from API response · explain & risk-check →cat config.json | jq -r '.database.host'Extract raw string value · explain & risk-check →jq -r '.[] | [.name, .status] | @csv' pods.jsonConvert JSON array to CSV · explain & risk-check →jq 'del(.password)' config.jsonRemove a key from JSON · explain & risk-check →Use `jq -e 'expression' && echo ok || echo fail` in CI scripts — jq exits non-zero if the result is null/false, making it a powerful JSON-aware conditional.
Reference text is hand-written and may be incomplete — check man jq for your version. Test destructive commands on a non-production system first.