JSON to Go Struct

Generate Go structs with json tags from JSON instantly. Handles nested objects, arrays, nullable pointers, and omitempty tags. Free, runs in your browser.

100% Client-Side Your data never leaves your browser Free · No Sign-Up
JSON Input
Go Output

How to Use

  1. Paste or type your JSON into the left panel. The tool validates it in real time.
  2. Optionally set a Root struct name (default: RootObject).
  3. Click Generate Go Struct or wait for real-time conversion.
  4. Click Copy to copy the output to your clipboard.

Type Mapping

  • nullinterface{}
  • string → string
  • integer number → int
  • floating-point number → float64
  • boolean → bool
  • array → []T
  • nullable/optional → pointer (*T)
  • nested object → separate named struct

Example

Given this JSON:

{"name": "Alice", "age": 30, "address": {"city": "London"}}

The tool generates:

type Address struct {
	City string `json:"city"`
}

type RootObject struct {
	Name    string  `json:"name"`
	Age     int     `json:"age"`
	Address Address `json:"address"`
}

FAQ

What does this tool generate?

It generates Go struct type declarations with json struct tags. Each nested JSON object becomes its own named struct. Array fields become slices ([]T).

How are nullable fields handled?

JSON null values produce interface{} types. Fields that are absent in some array items are represented as pointers (*T) with omitempty json tags.

Why are pointer types used?

In Go, pointers are the idiomatic way to represent optional or nullable values. A *string can be nil (absent/null) whereas a string cannot.

What json tags are generated?

Every field gets a json tag matching the original JSON key. Fields that may be absent (not present in all array items) also get ,omitempty to allow omission when marshaling.

Is my data sent to a server?

No. The entire conversion runs in your browser. No data leaves your machine.