Skip to main content
Back to tools

JSON to Go Struct

Generate Go structs with json tags from a JSON object

About JSON to Go Struct

JSON to Go Struct lets you generate go structs with json tags from a json object.

Category: Converters.

Frequently asked questions

What are json struct tags?

Go struct tags (e.g. `json:"name"`) tell the encoding/json package which JSON key maps to each struct field during Marshal and Unmarshal.

How are nested objects handled?

Each nested JSON object generates a separate named struct. The parent struct references it by name, matching Go conventions.

When is float64 vs int used?

If the sample number has no decimal part, the converter outputs int. If it has a fractional part, it outputs float64. Adjust to int64 or float32 as needed.

How do I unmarshal JSON into the struct?

Use json.Unmarshal([]byte(jsonStr), &root) or json.NewDecoder(r.Body).Decode(&root) — the generated struct tags wire everything up automatically.

Related tools