[jq] Sum numbers

Created on November 30, 2026

Use the add filter on an array of numbers. In this example, save the following data as sample.json.

[
  {
    "name": "Tom",
    "score": 10
  },
  {
    "name": "Bob",
    "score": 30
  },
  {
    "name": "Alice",
    "score": 20
  }
]

Build an array of score values and pass it to add.

cat sample.json | jq '[.[].score] | add'
60
jq