[jq] Remove duplicate elements from an array

Created on November 30, 2026

Use unique to discard duplicates and return the remaining elements in sorted order.

echo '[1, 2, 2, 3, 1]' | jq 'unique'
[
  1,
  2,
  3
]

For an array of objects, use unique_by(.property) to deduplicate by a property.

jq