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.
How to Use
- Paste or type your JSON into the left panel. The tool validates it in real time.
- Optionally set a Root struct name (default:
RootObject). - Click Generate Go Struct or wait for real-time conversion.
- Click Copy to copy the output to your clipboard.
Type Mapping
null→interface{}- 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.