Cheatsheet Pages / jq Cheatsheet

How to combine conditions in jq — and, or, not

One condition is not enough: you need rows that pass several tests, or fail one.

Every filter was executed against the cheatsheet's sample config.json with jq 1.7 before publishing; the sample file sits at the bottom of the cheatsheet so you can reproduce every output.

jq -r '.users[] | select(.age > 18 and .active) | .name' config.json
# output: ana        (carla is inactive, bruno is 17)
jq -r '.users[] | select(.active | not) | .name' config.json
# output: carla
jq Cheatsheet one-page card — 30 filters that actually work
The full one-page card — jq Cheatsheet. Get the complete cheatsheet on GitHub