[jq] Count the elements of an array

Created on November 30, 2026

You can apply jq's length filter to an array to count its elements. This example counts the objects in the top-level array.

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