jqiy
Back to Home

jq Command Examples: 25 Practical JSON Processing Recipes (2026)

Master jq with 25 practical command examples. Learn to parse, filter, transform, and query JSON data like a pro. Includes real-world recipes for developers.

Getting Started with jq

jq is a lightweight and flexible command-line JSON processor. It's like sed/awk for JSON data — you can slice, filter, map, and transform structured data with ease.

Install jq: brew install jq (macOS), apt install jq (Linux), or download the binary from jqlang.github.io/jq/.

Basic syntax: cat data.json | jq '.key' — this extracts the value of 'key' from a JSON object.

You can also try jq online at jqiy.com without installing anything.

Essential jq Recipes

1. Pretty-print JSON: cat data.json | jq '.'

2. Extract a field: cat data.json | jq '.name'

3. Extract nested field: cat data.json | jq '.address.city'

4. Access array elements: cat data.json | jq '.items[0]'

5. Slice arrays: cat data.json | jq '.items[0:3]'

6. Select objects by condition: cat data.json | jq '.items[] | select(.price > 100)'

7. Transform data: cat data.json | jq '{name: .user.name, email: .user.email}'

8. Count items: cat data.json | jq '.items | length'

9. Get unique values: cat data.json | jq '[.items[].category] | unique'

10. Build arrays: cat data.json | jq '[.items[] | {name, price}]'