[jq] Convert a string to a number

Created on November 28, 2026

You can use tonumber to convert a string to a number. This example converts each age property from a string to a number and outputs the result.

echo '[{"name": "Taro", "age": "25"},{"name": "Satoshi", "age": "30"}]' | jq '.[].age | tonumber'

The command produces the following output.

25
30
jq