Pure Go implementation of jq for processing JSON data with arbitrary-precision arithmetic and YAML support.
gojq is a complete reimplementation of the jq command-line JSON processor written in Go. It provides the same query syntax and functionality as jq for filtering, transforming, and manipulating JSON data through a declarative query language. The tool supports all standard jq operations including object/array access, filtering, mapping, arithmetic operations, and custom function definitions.
gojq offers several advantages over the original jq implementation. It supports arbitrary-precision integer arithmetic, preserving the precision of large numbers during calculations, while jq converts large integers to floating-point. The tool includes YAML input and output support through --yaml-input and --yaml-output flags. It also fixes several jq behavioral issues, including string indexing, handling files without trailing newlines, and improved time parsing with nanosecond support.
The tool can be used both as a standalone command-line utility and as a Go library. As a library, it provides a gojq.Parse() function to compile queries and a query.Run() method that returns an iterator for processing results. The library API supports custom functions, module loading, environment variable access, and context-based execution for timeout control.
# via Homebrew
brew install gojq
# via Go
go install github.com/itchyny/gojq/cmd/gojq@latest