jq 'length' data.json

Category: Data Science & Analysis

jq 'length' data.json

Count the elements in a JSON array

The length filter returns the number of elements for arrays, characters for strings, or keys for objects. Applied to a top-level array this is a quick record count for a JSON dataset. It streams cheaply for most inputs. This is the jq counterpart of wc -l for JSON data.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.