Stage 01 · Write · Researched comparison
Best Go JSON Libraries in 2026
The standard library encoding/json is the first pick for most Go projects. It is free, maintained by the Go team and handles the common cases without extra dependencies. Teams that need faster encoding and decoding should look at goccy/go-json as a drop-in replacement. Projects that need JSON Schema validation should use santhosh-tekuri/jsonschema, which is separate from encoding work.
By Shihab Mia
Published 27 Nov 2026 · 6 tools compared
We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.
Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.
Key takeaways
- encoding/json ships with Go, needs no install and is the safest default for new code.
- goccy/go-json aims to be a drop-in replacement with the same API surface.
- JSON Schema validation is a separate job from encoding, so tools like santhosh-tekuri/jsonschema cover it.
- All libraries listed here are free and open source; check each repository for its current license terms.
Who each pick is for
- Most Go projects that need standard JSON handlingencoding/json
- Teams wanting a faster drop-in replacement for encoding/jsongoccy/go-json
- Reading specific values from large JSON without full unmarshalinggjson
- Setting or deleting values in JSON without full unmarshalingsjson
- Validating JSON documents against JSON Schema draftssanthosh-tekuri/jsonschema
- Code-generated marshaling for hot pathseasyjson
Comparison
| Tool | Best for | Standout feature | Listed starting price | Free plan or trial |
|---|---|---|---|---|
| 1encoding/json | Most Go projects that need standard JSON handling | Ships with the Go toolchain | Free (open source) | Free plan |
| 2goccy/go-json | Teams wanting a faster drop-in replacement for encoding/json | Aims for API compatibility with encoding/json | Free (open source) | Free plan |
| 3gjson | Reading specific values from large JSON without full unmarshaling | Path-style queries for pulling single values | Free (open source) | Free plan |
| 4sjson | Setting or deleting values in JSON without full unmarshaling | Path-based updates to existing JSON | Free (open source) | Free plan |
| 5santhosh-tekuri/jsonschema | Validating JSON documents against JSON Schema drafts | Supports multiple JSON Schema drafts | Free (open source) | Free plan |
| 6easyjson | Code-generated marshaling for hot paths | Generates marshal and unmarshal code from struct definitions | Free (open source) | Free plan |
How we picked
We picked libraries that are actively maintained, have a public repository and do a clear job for Go developers: encoding, decoding, partial reads and writes, or schema validation. We checked each project's documentation for supported Go versions, API compatibility and stated limits. We did not run benchmarks. Prices and licenses can change, so confirm the current terms on each repository before adopting a dependency.
The tools, one by one
encoding/json
Best for most Go projects that need standard JSON handling

What it is and where it fits
encoding/json is part of the Go standard library, so there is nothing to install and no version to pin beyond your Go release. It handles struct tags, maps, slices, interfaces and streaming with Encoder and Decoder. The API is the reference that most other Go JSON libraries imitate.
Because it is maintained by the Go team, behavior changes are rare and follow the Go release cycle. The main trade-offs are speed on very large payloads and the lack of built-in JSON Schema validation. For most services, CLIs and internal tools, it is enough. Skip it only when profiling shows JSON handling is a real bottleneck.
Standout: Ships with the Go toolchain
Free (open source), as listed by the vendor (encoding/json website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Ships with the Go toolchain
- stable and widely documented
Drawbacks
- Slower than some third-party encoders on large payloads
- limited schema support
Skip it if this limit matters to you: slower than some third-party encoders on large payloads.
Verdict. A sensible pick for most Go projects that need standard JSON handling.
Alternatives in this guide: goccy/go-json, gjson, sjson
goccy/go-json
Best for teams wanting a faster drop-in replacement for encoding/json

What it is and where it fits
goccy/go-json is a JSON library that mirrors the encoding/json API while using different internals for speed. In many codebases you can swap the import path and keep the rest of your code. It supports struct tags, custom marshalers and streaming, and the repository documents its compatibility goals.
It is a good fit when JSON parsing shows up in profiles and you want a low-friction change. The trade-off is that you now depend on a third party for a core data path, so pin versions and run your own tests against real payloads. Projects with strict dependency policies or unusual JSON shapes should benchmark and test before switching.
Standout: Aims for API compatibility with encoding/json
Free (open source), as listed by the vendor (goccy/go-json website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Aims for API compatibility with encoding/json
- offers faster encode and decode paths
Drawbacks
- Third-party dependency to track
- edge-case behavior can differ from the standard library
Skip it if this limit matters to you: third-party dependency to track.
Verdict. A sensible pick for teams wanting a faster drop-in replacement for encoding/json.
Alternatives in this guide: encoding/json, gjson, sjson
gjson
Best for reading specific values from large JSON without full unmarshaling

What it is and where it fits
gjson lets you query JSON with path expressions such as user.name or a nested array index. It is useful when you only need a few fields from a large document and do not want to define and unmarshal into a full struct. The repository documents the path syntax and available helper methods.
It pairs well with encoding/json: use gjson for quick reads and the standard library when you need full typed decoding. It is not a replacement for a complete encoder, and it does not validate schemas. Teams that need to write JSON should look at the sibling project sjson or use the standard library.
Standout: Path-style queries for pulling single values
Free (open source), as listed by the vendor (gjson website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Path-style queries for pulling single values
- avoids defining full structs for partial reads
Drawbacks
- Focused on reading, not a general encoder
- not a schema validator
Skip it if this limit matters to you: focused on reading, not a general encoder.
Verdict. A sensible pick for reading specific values from large JSON without full unmarshaling.
Alternatives in this guide: encoding/json, goccy/go-json, sjson
sjson
Best for setting or deleting values in JSON without full unmarshaling

What it is and where it fits
sjson is the write-side companion to gjson. It sets or deletes values in a JSON document using path expressions, which helps when you need to patch a payload without defining a full Go type for it. The repository documents the path syntax and return values.
Use it for small, targeted edits to JSON you already have in memory. It is not meant for building documents from scratch or for schema validation. For most application code, typed structs and encoding/json remain clearer. Reach for sjson when the document shape is dynamic or only partially known.
Standout: Path-based updates to existing JSON
Free (open source), as listed by the vendor (sjson website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Path-based updates to existing JSON
- avoids round-tripping through structs
Drawbacks
- Narrow scope
- not a general-purpose encoder or validator
Skip it if this limit matters to you: narrow scope.
Verdict. A sensible pick for setting or deleting values in JSON without full unmarshaling.
Alternatives in this guide: encoding/json, goccy/go-json, gjson
santhosh-tekuri/jsonschema
Best for validating JSON documents against JSON Schema drafts

What it is and where it fits
santhosh-tekuri/jsonschema is a JSON Schema validator for Go. It compiles schemas and validates documents against them, reporting errors with paths so you can point at the failing field. The repository documents supported drafts and how to load schemas from files or URLs.
Use it when your service accepts JSON from other systems and you need to enforce a contract beyond Go struct types. It does not replace encoding/json for decoding; you typically validate first, then decode. Projects with simple internal payloads may not need schema validation at all.
Standout: Supports multiple JSON Schema drafts
Free (open source), as listed by the vendor (santhosh-tekuri/jsonschema website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Supports multiple JSON Schema drafts
- reports validation errors with paths
Drawbacks
- Validation is separate from encoding
- schema setup adds code
Skip it if this limit matters to you: validation is separate from encoding.
Verdict. A sensible pick for validating JSON documents against JSON Schema drafts.
Alternatives in this guide: encoding/json, goccy/go-json, gjson
easyjson
Best for code-generated marshaling for hot paths

What it is and where it fits
mailru/easyjson generates JSON marshaling code for your structs. You annotate types and run the generator, and the resulting code avoids reflection at runtime. The repository documents the generator, build tags and the supported types.
It fits services where JSON encoding is a measured hot path and you can accept a generation step. The cost is build complexity: generated files need to be regenerated when structs change, and CI must catch drift. For most projects, encoding/json or a drop-in replacement is simpler. Choose easyjson when profiling justifies it.
Standout: Generates marshal and unmarshal code from struct definitions
Free (open source), as listed by the vendor (easyjson website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Generates marshal and unmarshal code from struct definitions
- avoids reflection at runtime
Drawbacks
- Adds a code generation step to the build
- generated code must be kept in sync
Skip it if this limit matters to you: adds a code generation step to the build.
Verdict. A sensible pick for code-generated marshaling for hot paths.
Alternatives in this guide: encoding/json, goccy/go-json, gjson
Who should use what
New Go services and internal tools should start with encoding/json and only switch if profiling shows JSON is a bottleneck. High-throughput APIs that want a low-friction change can try goccy/go-json, with tests against real payloads. Code that reads a few fields from large or dynamic documents fits gjson, and targeted edits fit sjson. If you accept JSON from other systems and need contract enforcement, add santhosh-tekuri/jsonschema. Teams with measured hot paths and a code generation step can evaluate mailru/easyjson.
Questions to settle before you buy
What to check before you buy
- Confirm the library supports your Go version and is still receiving commits.
- Check the license terms in the repository before adding it as a dependency.
- Run your own tests with real payloads, including edge cases like nulls and large numbers.
- Decide whether you need schema validation as a separate step.
- Pin the version and review release notes before upgrading.
FAQ
Is encoding/json fast enough for most services?
For many services, yes. It is stable and needs no dependency. Measure your own workload before replacing it. If JSON parsing is a small share of request time, a faster library will not change much, and the standard library keeps your dependency list shorter.
Can I swap goccy/go-json in without code changes?
goccy/go-json aims for API compatibility with encoding/json, so in many cases changing the import path is enough. Edge cases can differ, especially around custom marshalers and unusual types. Keep tests that compare output against the standard library for your real structs before and after the switch.
Do I need a separate library for JSON Schema validation?
Yes, if you need schema validation. Encoding libraries decode into Go types but do not enforce a JSON Schema. santhosh-tekuri/jsonschema compiles schemas and validates documents. A common pattern is to validate first, then decode with encoding/json or a replacement.
Are these libraries free to use?
All the libraries listed here are free and open source. Each repository states its license, and terms can change, so read the license file before adopting a dependency in commercial code. There is no paid tier for any of these projects.
What about pasting JSON into online formatters?
Online JSON formatters are convenient, but do not paste secrets, tokens or production data into third-party web pages. Prefer tools that run locally in the browser or offline. For Go work, formatting and validation inside your editor or with local command-line tools avoids sending data to a server.
Sources we checked
Method: how we score · editorial policy.
Change log. First published 27 Nov 2026.