JSON to Go Structures Converter
Generates Go struct definitions from JSON using a json-to-go port, formatted with gofmt. Keys become exported CamelCase fields with json:"..." tags; nested objects become inline anonymous structs and null becomes any.
Writing a struct to json.Unmarshal a third-party REST API response.
When to use it
- Writing a struct to json.Unmarshal a third-party REST API response.
- Bootstrapping request and response types for a Go HTTP handler from example payloads.
How to use
- Paste a JSON object or array into the left editor.
- Read the generated struct; the root type is always named AutoGenerated.
- Copy it into your package, rename the type and extract inline structs into named types if you reuse them.
JSON
{
"id": 42,
"user_name": "ada",
"score": 9.5,
"active": true,
"deleted_at": null,
"tags": ["go", "json"],
"address": { "city": "Tokyo", "zip": "100-0001" }
}Go struct
type AutoGenerated struct {
ID int `json:"id"`
UserName string `json:"user_name"`
Score float64 `json:"score"`
Active bool `json:"active"`
DeletedAt any `json:"deleted_at"`
Tags []string `json:"tags"`
Address struct {
City string `json:"city"`
Zip string `json:"zip"`
} `json:"address"`
}Details and limitations
Generation runs in the browser. There are no settings for the type name, inline vs named structs, or tags.
Initialisms are capitalized (id becomes ID) and snake_case becomes CamelCase, with the original key kept in the json tag.
Whole numbers become int (int64 when large), decimals float64. null, empty arrays and mixed arrays become any or []any.
When objects in an array differ, keys missing from some get ,omitempty.
FAQ
Can I convert a JSON array at the root?
Yes. It produces type AutoGenerated []struct{...}, merging the fields of all objects in the array.
Why is my null field typed any?
A null value carries no type information. Replace any with a pointer such as *string or *time.Time to keep nil support.
Does it generate named nested structs?
No. Nested objects are inline anonymous structs. Move them to named types manually if you need to reference them.