[jq] Get the maximum value in an array

Created on November 30, 2026

Use max to find the largest element.

echo '[3,10,7]' | jq 'max'
10

For an array of objects, use max_by to return the entire element with the highest value for a property.

echo '[{"name":"A","score":70},{"name":"B","score":90}]' | jq 'max_by(.score)'
{
  "name": "B",
  "score": 90
}
jq