JSON to Go Struct Generator
Paste JSON and get Go structs with json tags — nested structs, slices and omitempty inferred for you, live in your browser.
This json to go struct generator turns a sample document into gofmt-style type declarations you can drop straight into a package. It writes exported field names, keeps the original keys in `json:"..."` tags, and picks int64 or float64 based on the numbers it sees. Nested objects become their own named structs and arrays of objects merge into one slice type, so a json to golang struct stays readable instead of a wall of interface{}. Fields that are absent from some records, or ever null, get an omitempty tag. Use it as a quick go struct generator when you’re modelling an API response or a config file.
How it works
- 1
Paste JSON
Put a representative object or array in the left pane. The more complete the sample, the better the json to go type inference.
- 2
Watch the structs build
The right pane updates live with structs, json tags, slices and nested types as you edit.
- 3
Name it and copy
Set the root struct name, then copy the code or download a types.go file.
Instant & 100% private — nothing is uploaded
Everything runs locally in your browser. Your code, text and files are processed on your own device and are never sent to a server — so there are no upload waits, no size limits from us, and nothing is ever stored or logged.
Frequently asked questions
- How are numbers typed?
- A whole number becomes int64 and a number with a fraction becomes float64. If a field holds both kinds across records, the wider float64 wins.
- When does it add omitempty?
- When a field is missing from some elements of an array of objects, or when a value is null, the go struct generator adds ,omitempty to the json tag.
- What about nested objects and arrays?
- Nested objects turn into separate named structs, and an array of objects merges into a single []Struct so you get one clean type instead of many.
- What happens with mixed or null values?
- A slice with mixed element types falls back to []interface{}, and a null value is typed as interface{}, since Go has no direct null.
- Does anything leave my browser?
- No. This json to golang struct tool runs client-side only; your JSON is never uploaded.
More tools
More from the Hivly network
Free sister tools on our other sites.