
Basics
7 entries| Syntax | Description |
|---|---|
jq . file.json | Pretty-print JSON |
jq -c . file.json | Compact one-line JSON |
jq -r .name file.json | Raw string without quotes |
jq .user.email file.json | Read a nested field |
jq .name // "unknown" | Default when null or missing |
jq .items[0] | First array element |
jq .items[-1] | Last array element |
Arrays and objects
6 entries| Syntax | Description |
|---|---|
jq .items[] | Stream each array item |
jq .items[1:4] | Slice array indexes 1, 2, 3 |
jq keys | List object keys |
jq has("email") | True if the key exists |
jq length | Length of array, object, or string |
jq type | JSON type of the input |
select and map
5 entries| Syntax | Description |
|---|---|
jq ".[] | select(.active)" | Keep matching objects |
jq "map(.email)" | Project one field into an array |
jq "map(select(.score > 50))" | Filter then keep an array |
jq ".[] | select(has("email"))" | Keep objects with a key |
jq "select(.role == "admin")" | Match a string field |
Transform
6 entries| Syntax | Description |
|---|---|
jq "{name, id}" | Build a smaller object |
jq "del(.password)" | Remove a field |
jq ".count += 1" | Update a number field |
jq "to_entries" | Object to key/value array |
jq "from_entries" | Key/value array to object |
jq "flatten" | Flatten nested arrays |
Sort and aggregate
6 entries| Syntax | Description |
|---|---|
jq "sort_by(.name)" | Sort objects by a field |
jq "unique_by(.email)" | Deduplicate by a field |
jq "group_by(.team)" | Bucket objects by a field |
jq "map(.price) | add" | Sum a numeric field |
jq "min_by(.age)" | Object with the lowest field |
jq "max_by(.score)" | Object with the highest field |
Strings and CLI
6 entries| Syntax | Description |
|---|---|
jq -r ".name | ascii_downcase" | Lowercase a string |
jq -r "split("/")" | Split a string into an array |
jq -r "join(",")" | Join an array into a string |
jq "select(.msg | test("error"; "i"))" | Regex match, ignore case |
curl URL | jq . | Pretty-print an HTTP JSON body |
jq -n --arg n "$NAME" '{name:$n}' | Build JSON from a shell variable |
Sources
1 entries| Syntax | Description |
|---|---|
| jq manual: command-line filters and options. Browser playgrounds can support a smaller subset. |
Related Cheatsheets
ProgrammingNew
Barcode Formats

Code 128, Code 39, EAN and UPC inputs, check digits, export settings, and print checks for barcode generation.
Programming
JavaScript ES6+

Modern JavaScript syntax: destructuring, arrow functions, promises, modules, and built-in methods
Programming
Python Essentials

Python syntax, data structures, comprehensions, built-in functions, and common patterns