jq

Command-line JSON processor and transformer.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

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.

Common flags
FlagMeaning
-r --raw-outputOutput raw strings without JSON quotes
-c --compact-outputCompact output on one line
-s --slurpRead all input into an array
-e --exit-statusReturn exit code 1 if result is false/null
Examples
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 →
Pro tip

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.

Related
yq curl kubectl
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man jq for your version. Test destructive commands on a non-production system first.