JSON to Go struct

Generate Go struct definitions with json tags from a sample JSON document.

Converted in this browser. Nothing is sent anywhere.

Objects become struct types (nested objects get their own types), arrays become slices, fields missing in some array elements get omitempty. int64/float64/string/bool/any cover the value space.

How to use

  1. Paste a JSON sample.
  2. Name the root struct.
  3. Copy the generated Go code.

What it supports

Objects become nested structs; arrays infer the element type from the merged item shape; null fields become *T. Keys are exported via Go-style names with a json tag for the original key. Input up to 2 MB, nesting to 40 levels.

Related tools

Related guides