- Home
- JSON Tools
- gojq
gojq
What it is
gojq is a free, open-source implementation of the jq command written in Go. Its command-line tool applies jq queries to JSON input, including filtering, selecting fields, and updating data, and it can handle multiple input values. It also supports YAML input and output. For integer calculations, gojq supports arbitrary precision for addition, subtraction, multiplication, modulo, and divisible division. The project describes the software as portable and lists Linux, macOS, Windows, and self-hosted use. Go applications can embed gojq as a library, parse and run queries, compile queries for reuse, and configure custom functions and iterators. Documented installation options include Homebrew, mise, Zero Install, building from source, and Docker images. Library use has configuration considerations: operating system environment variables are unavailable to queries by default, and module loading is disabled by default. Queries may also run without output or produce infinitely many values; the project recommends RunWithContext to limit execution time. Compatibility limits include no preserved object key order, no support for jq’s NaN, Infinity, or leading-zero number extensions, and differences in some regular-expression syntax. The software is released under the MIT License.
For and against
For
- Reads and writes YAML
- Supports arbitrary-precision integer operations
- Can be embedded as a Go library
- Available for Linux, macOS, and Windows
Against
- Does not preserve object key order
- Some jq extensions and regex syntax differ
- Library queries may run indefinitely without output
The verdict
gojq provides a portable jq-style command and an embeddable Go library, with YAML support and arbitrary-precision integer operations. Users should account for its documented compatibility differences and configure safeguards for library queries that may not finish.
Who it suits
gojq suits command-line users who need jq-style queries for JSON or YAML, and Go developers who want to embed query support in an application. Its documented compatibility limits matter to users moving jq queries across implementations.
Plans and prices
Free
MIT-licensed open-source software · CLI and Go library
Read 11 Oct 2026 · github.com
On the record
- Compatibility limits
- gojq does not preserve object key order and lacks jq's keys_unsorted function and --sort-keys option.github.com · read 11 Oct 2026
- Environment access
- For library use, OS environment variables are inaccessible to queries by default for security reasons and can be enabled with a configured environment loader.github.com · read 4 Oct 2026
- Execution limits
- Library queries may emit infinitely many values or run without producing output, and the README recommends RunWithContext to limit execution time.github.com · read 4 Oct 2026
- Install options
- The project documents installation through Homebrew, mise, Zero Install, go install, and Docker.github.com · read 11 Oct 2026
- JSON queries
- The command applies jq queries to JSON input, including filtering, field selection, and updates.github.com · read 4 Oct 2026
- Library integration
- Go applications can parse and run queries with gojq, compile queries for reuse, and configure custom functions and iterators.github.com · read 4 Oct 2026
- Library limits
- The library requires query inputs to use []any for arrays and map[string]any for maps, and warns that queries can produce infinite results or run without producing output.github.com · read 11 Oct 2026
- Library security
- For library use, OS environment variables are inaccessible to queries by default; a caller can configure an environment loader.github.com · read 11 Oct 2026
- License
- The project is released under the MIT License.github.com · read 11 Oct 2026
- Limits
- gojq does not preserve object key order and therefore does not provide the keys_unsorted function or the --sort-keys option.github.com · read 4 Oct 2026
- Module loading
- The library's module feature is disabled by default and can be configured with a module loader.github.com · read 4 Oct 2026
- Number precision
- gojq supports arbitrary-precision integer calculations for addition, subtraction, multiplication, modulo, and divisible division.github.com · read 4 Oct 2026
- Numbers
- gojq supports arbitrary-precision integer calculations, while mathematical functions such as floor and round convert integers to floating-point numbers.github.com · read 11 Oct 2026
- Other limits
- The README lists unsupported jq features, including some functions and flags, JSON extensions such as NaN and Infinity, and some regular-expression features.github.com · read 11 Oct 2026
- Portability
- The README describes gojq as implemented purely in Go and completely portable.github.com · read 11 Oct 2026
- Purpose
- gojq is a pure Go implementation of the jq command-line JSON processor and can also be embedded as a library in Go products.github.com · read 11 Oct 2026
- Queries
- The CLI runs jq-style queries against JSON input and supports multiple input values.github.com · read 11 Oct 2026
- Support
- The project directs users to report bugs through its GitHub Issues page.github.com · read 11 Oct 2026
The review
gojq is a jq-style query tool for JSON, offered as a command-line program and a library for Go applications. It is best suited to developers who value portability, YAML support, or embedding queries in Go software. Its breadth is useful, though compatibility gaps matter for scripts that rely on specific jq behavior.
Overview
The command handles filtering, field selection, and updates, and it can process multiple input values. YAML input and output extend it to workflows that move between JSON and YAML. Written in Go, gojq is designed to be portable and can be installed through Homebrew, mise, Zero Install, source builds, or Docker images.
That portability comes with a compatibility tradeoff. gojq does not preserve object key order, so it omits keys_unsorted and the --sort-keys option. It also rejects jq’s NaN, Infinity, and leading-zero number extensions, and some regular-expression syntax differs. Teams moving existing jq scripts should check these differences against their actual queries before switching.
Key features
Queries and numeric handling
jq-style queries cover common JSON work: selecting fields, filtering records, and updating values. Multiple input values make the CLI practical for streams of separate JSON inputs. Integer addition, subtraction, multiplication, modulo, and divisible division use arbitrary precision, avoiding fixed-width limits in those operations. That precision does not extend to every calculation: functions such as floor and round convert integers to floating-point numbers.
YAML and Go integration
YAML input and output help when a workflow needs to query or emit YAML alongside JSON. As a Go library, gojq lets applications parse and run queries, compile queries for reuse, and provide custom functions and iterators. Callers must represent arrays as []any and maps as map[string]any, a concrete integration constraint for applications with other data structures.
Library safeguards and behavior
Queries cannot read operating-system environment variables by default, which gives library callers a secure starting point; an application can explicitly configure an environment loader when access is needed. Module loading is also disabled by default and requires a configured loader. Queries can produce infinitely many values or run without producing output, so library integrations should use RunWithContext to limit execution time. This makes the library flexible, but puts responsibility for execution limits on the host application.
Pricing
gojq is free and open source under the MIT License. The Free plan costs nothing and includes both the command-line tool and Go library. There is no paid tier or trial to weigh against those features, making it a straightforward option for individual developers and teams able to work within its compatibility and integration constraints.
Platforms
gojq supports Linux, macOS, Windows, and self-hosted environments. Its documented installation routes include Homebrew, mise, Zero Install, building from source, and Docker images, giving developers several ways to fit it into their existing setup.
Who it's for
Choose gojq when you need jq-style queries across these platforms, YAML input or output, arbitrary-precision integer operations, or query execution embedded in a Go product. It is a particularly practical fit when portability and Go integration matter more than exact compatibility with jq.
Look elsewhere if your scripts depend on preserved object-key order, jq’s numeric extensions, or regular-expression behavior that gojq does not support. Go library users should also be ready to provide the required input types and set execution limits for queries.
Pros and cons
- Pro: The CLI and Go library cover both standalone querying and application integration, so teams can use the same project in scripts and Go software.
- Pro: YAML input and output expand its use beyond JSON-only pipelines.
- Pro: Arbitrary-precision integer arithmetic protects several common operations from fixed-width overflow.
- Con: Missing jq functions and options, number extensions, and differences in regular-expression syntax can break workflows that expect closer compatibility.
- Con: Object-key order is not preserved, ruling it out for workflows that rely on that ordering.
- Con: Library queries can run indefinitely or produce unbounded output unless the host application configures a time limit.
Alternatives
jq is the direct alternative for readers who want the original jq project, including standalone binaries for Linux, macOS, and Windows. Choose gojq when a pure Go implementation, YAML support, or Go library integration better fits the job.
jless is a free MIT-licensed command-line tool for Linux and macOS. It may suit readers looking for a command-line option on those platforms.
jidoujisho is a free, open-source option for Android users.
JSONBuddy offers a free personal and educational perpetual license for a single user, with free minor updates and standard-like functionality. Readers who prefer a Windows application and that license model can consider it instead.
BracketView has a free plan for Linux, web, and Windows, with limits on uploads, snapshots, AI actions, and webhook usage. It is an option for readers whose needs fit those capped allowances.
Dadroit JSON Viewer offers a free non-commercial plan for files up to 50 MB, plus a Standard plan at $98 a year. Readers who want a viewer with a stated file-size cap or a paid Standard tier can compare it.
JSON Crack is a free, open-source online tool for web and browser extensions, with an approximate 300 KB limit that depends on data complexity and hardware. It may suit readers who want an online tool and can work within that limit.
JSON Editor is a free MIT-licensed JavaScript library for self-hosted and web use that requires a modern browser. It is an option for readers seeking a browser-based library.
Browse more options in JSON Tools.
Verdict
gojq is a strong fit for developers who want portable jq-style querying, YAML support, or a query library in Go, especially when arbitrary-precision integer operations matter. Its free MIT license removes pricing friction, but jq compatibility gaps and the need to manage library execution limits are real constraints. Choose gojq when those strengths match your workflow; choose another tool when exact jq behavior is essential.