Cheatsheet Pages / jq Cheatsheet

How to sum numbers in JSON with jq — add

A column of scores needs a total.

Every filter was executed against the cheatsheet's sample config.json with jq 1.7 before publishing; the sample file sits at the bottom of the cheatsheet so you can reproduce every output.

jq '.users | map(.score) | add' config.json
# output: 255      (92 + 75 + 88)

Good to know

add also concatenates arrays and merges objects — here it sums 92 + 75 + 88 = 255.

jq Cheatsheet one-page card — 30 filters that actually work
The full one-page card — jq Cheatsheet. Get the complete cheatsheet on GitHub