Cheat Sheet
The commands you keep forgetting, with a one-line description and a real example you can copy - 629 across 38 tools. Pick a tool in the sidebar, or search across all of them.
Showing jq. Choose another tool in the sidebar, or search all 629 commands.
jq
Slice, filter, and reshape JSON on the command line.
| Command | What it does | Example |
|---|---|---|
jq . | Pretty-print JSON. | echo '{"a":1}' | jq . |
.key | Get a field. | jq '.name' user.json |
.a.b | Get a nested field. | jq '.user.email' data.json |
.[] | Iterate over an array. | jq '.[]' items.json |
.[0] | Index into an array. | jq '.[0]' items.json |
.items[].name | Pull a field from each element. | jq '.items[].name' data.json |
select() | Keep only matching elements. | jq '.[] | select(.age > 30)' people.json |
map() | Transform every element. | jq 'map(.price)' cart.json |
keys | List an object’s keys. | jq 'keys' config.json |
length | Count items / string length. | jq '.items | length' data.json |
-r | Raw output (no surrounding quotes). | jq -r '.name' user.json |
{a, b} | Build a new object from fields. | jq '{name, id}' user.json |
group_by() | Group array elements. | jq 'group_by(.type)' items.json |
@csv | Emit CSV rows. | jq -r '.[] | [.id, .name] | @csv' rows.json |