JSON to Go Struct
JSON to Go Struct Generator
Convert a JSON object into Go struct definitions with proper json: tags. Nested objects become separate named structs. Works with any JSON shape — API responses, config files, or event payloads. Runs in your browser with no upload required.
Where Is This Useful?
json.Unmarshal(). Each nested object becomes its own named struct with matching json tags.How to Use
- Paste a JSON object in the input panel
- Set the root struct name (defaults to Root)
- Click Generate Struct or press Ctrl+Enter
- Copy the output or download as a
.gofile - Add
omitemptyand pointer types for optional or nullable fields in your editor
Type Mapping
- JSON string →
string - JSON integer →
int64 - JSON float →
float64 - JSON boolean →
bool - JSON null →
interface{} - JSON object → named
structwithjson:tags - JSON array →
[]ElementType
Frequently Asked Questions
What json tags does the generator add?
Every field gets a `json:"fieldname"` tag matching the original JSON key. This ensures encoding/json marshals and unmarshals correctly even if you rename the Go field.
How are nested objects handled?
Nested JSON objects become separate named Go structs, referenced by the parent struct as a field type. The nesting depth is unlimited.
What Go type does a JSON number become?
int64 for integers, float64 for floats. The generator checks whether the value has a fractional part to decide which to use.
What about null values?
JSON null maps to interface{}. In production you may want pointer types like *string or sql.NullString depending on your use case.
Can I use this for API responses?
Yes. Paste a real API response, generate the structs, then use json.Unmarshal() or json.NewDecoder() with the generated type in your HTTP client.
Is my JSON uploaded anywhere?
No. All processing runs locally in your browser.
Related Tools