Common jq Reduce Patterns: 9 Essential Techniques for JSON Aggregation
The reduce operator iterates over JSON values while maintaining an accumulator state, enabling everything from simple sums to complex grouping operations through the syntax reduce source as $var (init; body).
The reduce operator is a foundational construct in the jqlang/jq JSON processor. Unlike simple mapping operations, reduce maintains state across iterations through an accumulator variable, making it essential for aggregation tasks. According to the jq source code, the operator is tokenized as REDUCE in
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
Share the following with your agent to get started:
curl -s "https://instagit.com/install.md" Works with
Claude
Codex
Cursor
VS Code
OpenClaw
Any MCP Client
Maintain an open-source project? Get it listed too →