Skip to main content

jq Cheatsheet

jq is a lightweight command-line JSON processor, like sed/awk for JSON data. Supports filtering, mapping, transformation, and aggregation — essential for API debugging and data processing.

Updated: 2026-07-20·20 commands

Quick Start

``bash jq '.' data.json # Pretty-print jq '.name' package.json # Extract key jq '.dependencies | keys' pkg.json # List dependency names jq '.[] | select(.age > 30)' users.json # Filter array jq -r '.version' package.json # Raw output (no quotes) ``

Startup & Modes(20)

CommandLevel
jq --help
Show jq help
Basic
jq '.' file.json
Pretty-print JSON (format + color)
Basic
jq '.key'
Extract value of a key
Basic
jq '.a.b.c'
Extract nested key (chained access)
Basic
jq '.[]'
Iterate over array elements
Intermediate
jq '.[0]'
Get first array element
Basic
jq '.[] | .name'
Iterate array and extract each name
Intermediate
jq '. | {key1, key2}'
Select fields to construct new object
Intermediate
jq 'select(.age > 30)'
Filter array by condition
Intermediate
jq -r
Raw output (no quotes)
Basic
jq -c
Compact output (one JSON per line)
Basic
jq -f
Read jq filter from file
Intermediate
jq 'group_by(.key)'
Group by specified key
Expert
jq 'sort_by(.key)'
Sort by key
Intermediate
jq 'length'
Calculate array length
Basic
jq 'keys'
List all object keys
Basic
jq map select
Apply mapping to each array element
Intermediate
jq -s
Read multiple JSON objects into array (slurp)
Intermediate
jq -n
Use null input (test filters)
Intermediate
jq 'add'
Sum array elements
Intermediate

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-20.