[jq] Transform nested JSON values with walk

Created on November 30, 2026

Use walk to apply a filter throughout a JSON value. This example doubles every number, including numbers in nested arrays and objects.

printf '%s\n' '{"name":"Taro","score":10,"history":[20,{"score":30}],"active":true,"note":null}' |
  jq 'walk(if type == "number" then . * 2 else . end)'
{
  "name": "Taro",
  "score": 20,
  "history": [
    40,
    {
      "score": 60
    }
  ],
  "active": true,
  "note": null
}

walk processes the children of an array or object before applying the filter to the container itself. The filter doubles values of type number and returns the other values as they are, preserving the JSON structure.

Reference

jq