[jq] Transform each element of an array with map

Created on November 30, 2026

Use map to apply a filter to each array element and collect its results in a new array. This example doubles the input numbers.

echo '[1,2,3]' | jq 'map(. * 2)'
[
  2,
  4,
  6
]

Transform a field in every object

Here each element is an object. The filter increases its score by 10 and keeps its other fields.

echo '[{"name":"Taro","score":80},{"name":"Hanako","score":90}]' | jq 'map(.score += 10)'
[
  {
    "name": "Taro",
    "score": 90
  },
  {
    "name": "Hanako",
    "score": 100
  }
]

Transform the values of an object

Use map_values to apply a filter to the values in an object and retain its keys when the filter produces a value for each key.

echo '{"apple":100,"banana":200}' | jq 'map_values(. * 2)'
{
  "apple": 200,
  "banana": 400
}
jq