JSON to Go struct generator
Convert any JSON sample to a Go struct with `json:"..."` tags. Includes Unmarshal helpers. Runs in your browser; never uploads your data.
# context
Go developers reach for code generation when an API response has more than 5 fields. The standard library `encoding/json` package needs explicit struct tags to map snake_case or camelCase keys to Go field names. This tool emits the struct with tags + Unmarshal helpers ready to drop into a package.
JSON input
{
"id": 1,
"name": "Ada Lovelace",
"email": "[email protected]",
"active": true,
"roles": ["admin", "engineer"],
"createdAt": "2026-05-14T00:00:00Z"
} Output preview
package main
import "encoding/json"
func UnmarshalUser(data []byte) (User, error) {
var r User
err := json.Unmarshal(data, &r)
return r, err
}
type User struct {
ID int64 `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Active bool `json:"active"`
Roles []string `json:"roles"`
CreatedAt string `json:"createdAt"`
} → Open in JSON to Types generator (pre-filled)
# notes
- Default package name is `main`. Rename to match your module after generation.
- For `time.Time` instead of `string` on date fields, swap the type after generation — quicktype keeps dates as strings for portability.
- Pointer fields (`*string`) are used for nullable values when the sample contains explicit `null`.