JSON to Go Struct Generator

Paste JSON, get Go code instantly. Private, in your browser.

Input

Output

Ready
Ln 1, Col 1

Convert JSON to Go in one step

Paste JSON and get Go structs with json struct tags, ready for encoding/json. Field names are exported PascalCase, and the tags keep the original keys.

How to use it

  1. Paste a JSON sample into the Input panel, open a file, or drop it onto the page. A sample is already loaded so you can see the result.
  2. The Go code appears instantly in the Output panel and updates as you type.
  3. Rename the top-level type under Settings → Root type name, and use Sort keys to order fields alphabetically.
  4. Copy the code or Download it as Root.go.

What the Go generator produces

  • Exported fields with `json:"key"` tags; optional keys add omitempty.
  • Whole numbers become int64, decimals float64.
  • Missing or null values become pointers (*int64, *Address) so absent and zero can be told apart.
  • Nested objects become separate named structs; mixed values become any. Columns are aligned like gofmt.

Using the generated Go code

Decode JSON into the generated struct with the standard library:

var data Root
if err := json.Unmarshal(body, &data); err != nil {
	log.Fatal(err)
}
fmt.Println(data.Users[0].Name)

More JSON tools

All tools are free and run privately in your browser.

JSON to Go FAQ

Why are some fields pointers?

Fields that are missing or null in your sample become pointers such as *int64, so you can distinguish "not present" from a zero value. Missing fields also get omitempty.

Which Go version is required?

The code uses any, available since Go 1.18. For older versions replace any with interface{}.

Is my data uploaded to a server?

No. The JSON to Go runs entirely in your browser using JavaScript. Your data is never uploaded, logged or stored, and the tool keeps working offline after your first visit.