Go JSON v2 in Go 1.27: what breaks when you migrate from encoding/json

Go 1.27 ships encoding/json/v2. We ran v1 and v2 side by side on the same structs: here is every output that changed and the option or tag that fixes it.

Published Oct 3, 2026 9 min read By ImportStatic Editors

On this page

  1. What Go 1.27 changed even if you never import v2
  2. Go JSON v2 vs v1, side by side
  3. Tags that give the same JSON under v1 and v2
  4. Migrating one option at a time with DefaultOptionsV1
  5. What we measured: faster unmarshal, slower marshal
  6. Common questions

Go 1.27 put encoding/json/v2 in the standard library, and the part most people will miss is that you are already running it. Since Go 1.27, the old encoding/json package is implemented on top of the v2 engine with a set of compatibility options switched on. Your output should not change, but your error strings can, and the moment you change an import to encoding/json/v2 the defaults flip: nil slices become [], field names match case-sensitively, duplicate keys are rejected and time.Duration stops marshaling at all.