DEV.co
AI Coding Agents · mailru

easyjson

easyjson is a Go code generator that creates fast JSON marshaling/unmarshaling functions for structs without reflection, delivering 4–5× faster performance than Go's standard json package. It supports customization options like snake_case field naming and omitempty behavior while keeping generated code readable and maintainable.

Source: GitHub — github.com/mailru/easyjson
4.9k
GitHub stars
462
Forks
Go
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorymailru/easyjson
Ownermailru
Primary languageGo
LicenseMIT — OSI-approved
Stars4.9k
Forks462
Open issues98
Latest releasev0.9.2 (2026-03-14)
Last updated2026-03-14
Sourcehttps://github.com/mailru/easyjson

What easyjson is

easyjson generates type-safe MarshalEasyJSON/UnmarshalEasyJSON methods via code generation, avoiding reflection overhead and enabling unsafe string optimizations. It provides both easyjson.Marshaler interfaces and standard json.Marshaler compatibility, with configurable options for field naming, string interning, and memory pooling via sync.Pool.

Quickstart

Get the easyjson source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/mailru/easyjson.gitcd easyjson# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

High-throughput REST/gRPC APIs

Services handling thousands of JSON requests per second benefit significantly from the 4–5× performance gain, reducing latency and CPU overhead in request/response serialization.

Performance-critical microservices

When JSON is a bottleneck in data processing pipelines or services with tight latency SLAs, easyjson's code generation approach eliminates reflection cost and enables memory optimization via nocopy/intern tags.

Embedded/resource-constrained deployments

Projects targeting ARM or containerized environments benefit from lower CPU and memory usage; easyjson's buffer pooling and string interning reduce allocation pressure.

Implementation considerations

  • Code generation must run as a build step (easyjson -all <file>.go); integrate into go:generate directives or CI/CD to regenerate when structs change.
  • Requires a full Go build environment with GOPATH set; confirm compatibility with your build toolchain and containerization strategy.
  • Generated code uses unsafe for zero-copy string conversions during unmarshaling; audit for your security model if untrusted JSON is a concern.
  • String interning (intern tag) trades CPU for memory when few unique string values repeat frequently; profile to determine if it reduces allocations in your workload.
  • Manual marshaler/unmarshaler implementations can override generated ones; design struct hierarchies to leverage code generation without excessive custom overrides.

When to avoid it — and what to weigh

  • Dynamic JSON structures required — easyjson requires static Go struct definitions. If you need to handle arbitrary JSON shapes or frequent schema changes, the standard json package or third-party unmarshaling into map[string]interface{} is more suitable.
  • Case-insensitive field matching needed — Object keys are case-sensitive by design; case-insensitive matching is explicitly not supported due to performance considerations. Use standard json if this is critical.
  • Early-stage or frequently-changing projects — The README notes easyjson is 'still early in development' with potential bugs and missing features compared to encoding/json. If stability and feature parity matter more than performance, reconsider.
  • Vendoring/dependency isolation constraints — easyjson code generation requires GOPATH and invokes go run on temporary files. Some restricted build environments (monorepos, offline builds) may conflict with this approach.

License & commercial use

MIT License. Permissive OSI-approved license allowing commercial use, modification, and distribution with minimal restrictions (retain license notice).

MIT license permits commercial use. However, verify compliance with any other dependencies you bundle. No warranty is provided; assess risk tolerance for closed-source projects relying on a code-generation tool.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

Uses unsafe for no-copy string conversion during unmarshaling. Review the impact in your threat model if untrusted JSON from external sources is processed. No explicit security audit data provided; treat as a build-time tool risk, not a runtime cryptographic vulnerability. Validate generated code in security-critical paths.

Alternatives to consider

encoding/json (standard library)

Built-in, no dependencies, full feature parity with JSON spec, case-insensitive matching. Trade-off: 4–5× slower due to reflection; acceptable for non-performance-critical services.

json-iterator/go

Drop-in replacement for encoding/json with better performance (2–3× faster than standard but slower than easyjson) and more features. Avoids code generation; simpler integration but less customization.

ffjson

Similar code-generation approach to easyjson (on which easyjson was inspired). Older and less actively maintained; easyjson is the modern alternative.

Software development agency

Build on easyjson with DEV.co software developers

Evaluate easyjson for your high-throughput API or microservice project. Our engineers can help assess compatibility, integrate code generation into your CI/CD, and profile real-world gains. Contact us for a technical review.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

easyjson FAQ

How much performance gain should I expect?
README claims 4–5× faster than encoding/json and 2–3× faster than other JSON libraries in performance tests. Actual gains depend on struct complexity and workload; profile your specific use case.
Can I customize the generated code?
Yes. easyjson keeps generated code simple and readable so you can hand-edit or override with custom MarshalEasyJSON/UnmarshalEasyJSON implementations. Build tags and struct tags (nocopy, intern, omitempty) allow compile-time customization.
Does it work with generic or nested structs?
Unknown from provided data. Consult GoDoc or test with your struct hierarchy. Code generation applies to top-level and nested types, but support for Go generics (1.18+) is not explicitly mentioned.
Is it safe to use unsafe in production?
easyjson's unsafe usage is limited to unmarshaling (no-copy string conversion). If the JSON source is trusted or validated, the risk is low. Audit for your environment; no security guarantee is provided.

Work with a software development agency

From first prototype to production, DEV.co delivers software development services around tools like easyjson. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across ai coding agents and beyond.

Ready to optimize your Go JSON performance?

Evaluate easyjson for your high-throughput API or microservice project. Our engineers can help assess compatibility, integrate code generation into your CI/CD, and profile real-world gains. Contact us for a technical review.