Cheatsheet Pages / jq Cheatsheet

How to deduplicate values with jq — unique

The same city appears three times and you want each value once.

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 '.users | map(.city) | unique' config.json
# output: ["lisboa","madrid"]

Good to know

unique sorts as it deduplicates — feed it a plucked array of the field you care about.

jq Cheatsheet one-page card — 30 filters that actually work
The full one-page card — jq Cheatsheet. Get the complete cheatsheet on GitHub