← Back to Docs
Recipe

jq Cookbook

Practical jq recipes for slicing, dicing, and transforming JSON at the command line.

Pretty-print with color

cat data.json | jq .

Extract a single field

jq '.name' data.json

Filter array elements

jq '.[] | select(.status == "active")' data.json

Map and transform

jq '.[] | {id, label: .name}' data.json

Group by a key

jq 'group_by(.category)' data.json

Merge two JSON files

jq -s '.[0] * .[1]' a.json b.json

Want more? Check the full docs index for advanced filtering, regex matching, and CSV export recipes.