$ Convert JSON to Go structs
Paste a JSON payload and get Go struct definitions with json tags, ready for encoding/json.
JSON Input
Paste a JSON payload and generate typed definitions.
Generated Output
Structs ready to copy.
type Profile struct {
DisplayName string `json:"displayName"`
SignupAt string `json:"signupAt"`
}
type RootPayload struct {
Id int `json:"id"`
Email string `json:"email"`
IsActive bool `json:"isActive"`
Roles []string `json:"roles"`
Profile Profile `json:"profile"`
}Why use an online JSON to Go struct converter
Writing Go structs for a JSON API by hand is slow and error-prone: every field needs an exported PascalCase name, the right Go type and a json tag that matches the original key exactly. Miss one tag and encoding/json silently leaves the field empty.
This JSON to Go struct converter does that first pass for you. Paste a real response from the API you are integrating and you get one struct per JSON object, with json:"key" tags that keep the original key names, so json.Unmarshal fills every field on the first try.
Conversion runs entirely in your browser. That matters for Go backend work, where the JSON you paste is often a production payload with IDs, emails or tokens in it.
JSON to Go struct converter use cases
JSON to Go struct converter examples: input and output
Flat object with json tags
Nested object and string slice
snake_case keys stay intact in the tag
Common JSON to Go struct converter errors and how to fix them
cause:The struct fields are unexported (lowercase) or the json tag does not match the key, so encoding/json skips them.
fix:Keep the generated PascalCase field names and json tags; if you rename a field, leave the tag unchanged.
cause:The sample only contained whole numbers, so the field was inferred as int, but real data has decimals.
fix:Change the field to float64, or paste a sample that contains a decimal value for that field.
cause:The value was null or an empty array in the sample, so there was nothing to infer the type from.
fix:Replace interface{} with the real type, using a pointer (*string, *int) when the field can be null.
How developers use the JSON to Go struct converter in practice
The generator produces Id, Url and UserId. Go convention (and golint) prefers ID, URL and UserID — rename the field and keep the json tag as it is.
When you marshal structs back to JSON, append ,omitempty to the tag of optional fields (json:"nickname,omitempty") so zero values are not sent.
RFC 3339 strings such as 2026-01-02T10:00:00Z are inferred as string. Switch them to time.Time and encoding/json will parse them automatically.
When not to use the JSON to Go struct converter
JSON to Go struct converter limits and implementation notes
Only fields present in the pasted JSON appear in the struct. Merge several samples by hand if responses vary.
Slice element types are inferred from the first item; heterogeneous arrays need manual typing.
Related guides
Standards & references
Related developer tools
Frequently asked questions about the JSON to Go struct converter
How do I convert JSON to a Go struct?
Paste a representative JSON payload in the input. The converter infers a Go type for every field and emits one struct per JSON object, with a `json:"key"` tag that preserves the original key name for encoding/json.
How are JSON numbers mapped to Go types?
Whole numbers become int and numbers with a fractional part become float64. If a field can hold both in real data (for example 1 and 1.5), change it to float64 by hand, since inference only sees the sample you paste.
Why are field names converted to PascalCase?
encoding/json only reads and writes exported fields, and a Go field is exported only when it starts with an uppercase letter. The json tag keeps the original lowercase or snake_case key, so marshalling round-trips correctly.
How are nested objects and arrays handled?
Every nested object becomes its own named struct, and arrays become slices of the type of their first element ([]string, []Item). An empty array becomes []interface{} because there is no element to infer from.
What happens with null values?
A null field becomes interface{} because its real type cannot be inferred. Replace it with a pointer type such as *string or *int once you know what the field holds, so absence and zero values stay distinguishable.
Is my JSON sent to a server?
No. Conversion runs entirely in your browser, so API responses with tokens or customer data never leave your machine.
When should I use omitempty in Go JSON struct tags?
Add `,omitempty` to a struct tag (such as `json:"description,omitempty"`) when you want Go to omit that field from JSON serialization when its value is empty, zero, false, or nil.