jq

CLI>=1.6

Lightweight and flexible command-line JSON processor.

8 views

Installation

Homebrewbrew install jq
aptsudo apt install jq

Links

License

MIT

AI Agent Notes

Query and transform JSON on the command line

When to use

Parsing API responses, transforming JSON data, extracting fields

Examples
  • echo '{}' | jq '.key'
  • cat data.json | jq '.[] | .name'

Proven Recipes

Extract a field from JSON🟢 98% success
cat data.json | jq '.fieldName'
Filter array by condition🟢 95% success
cat data.json | jq '.[] | select(.age > 30)'
⚠ Common failures (1)
  • null outputCheck that input is an array with .[] not just .
Extract nested field🟢 97% success
cat data.json | jq '.user.address.city'
⚠ Common failures (1)
  • nullUse jq -e to exit non-zero on null, verify key names with jq 'keys'
Pretty-print JSON from API response🟢 99% success
curl -s https://api.example.com/data | jq '.'