$linuxjunkies
>

jq filter

also: jq expression, jq query

A jq filter is a pattern or expression that selects, transforms, or processes JSON data in the jq command-line tool. Filters can extract specific fields, perform calculations, or restructure JSON output.

jq is a lightweight command-line JSON processor, and a filter is the expression you write to manipulate that JSON. Filters are piped together to extract, transform, or analyze JSON data with precision.

Common jq filters include . (identity, returns the input), .fieldname (extracts a field), .[] (iterates over array elements), and select(condition) (filters based on criteria). You can chain filters with pipes: jq '.[] | select(.age > 30) | .name' would extract names of all people over 30 from a JSON array.

Example: given JSON {"name": "Alice", "age": 28}, the filter .name returns "Alice". More complex filters can map, group, aggregate, or conditionally process data—making jq powerful for API responses, log parsing, and data transformation without writing full scripts.

Related terms