Skip to content
callcount

encoding/json.Marshal

standard library

The 15th most-called standard-library function by production calls. Called 1,690 times across 226 modules; 1,470 of those run outside tests and generated code.

5% in production calls vs 2026-06-sample (1,404 → 1,470)

All of encoding/json → Docs on pkg.go.dev ↗

prod calls
1,470
non-test, non-generated
all calls
1,690
total callsites
modules
226
distinct callers
in loop
12%
of prod calls
in tests
10%
171 calls
resolved
100%
to a known target

resolution mix

How each call resolves

How each call was attributed. Only resolved kinds, where the target function is known, count toward the ranking. Interface dispatch and unresolved receivers are reported separately and never guessed. Read the taxonomy →

  • Package function100%A direct call to an exported package function, resolved by type.

estimate

Experimental

Estimated relative cost

Roughly 1.5× the estimated relative cost of fmt.Sprintf . Benchmarked at 642 ns/op × 1,470 production calls, normalized so fmt.Sprintf = 1.0.

This is not dollars and not a verdict. Per-op time depends heavily on inputs (argument sizes, contention, patterns), the benchmark ran on a single machine (darwin/arm64, go1.22.5), and static call counts are not runtime frequency. How this is estimated →

who calls this

Notable callers

Production calls into Marshal from notable Go projects. Open one on the map to see what else it hammers.

where it's called

Callsites in the wild

6 representative callsites of 1,690, prioritizing in-loop and non-test usage. We link to source, never display it.

top callers

The modules that reach for it

The modules that call Marshal most in this snapshot.

  • github.com/spf13/cobra59935%
  • k8s.io/apimachinery25015%
  • github.com/stretchr/testify22513%

siblings

More from encoding/json

The other most-called functions in this package. See all →