Paste a JSON sample and get clean Go structs with json tags — nested objects become their own structs, numbers infer to int64 or float64, and nullable fields become pointers. Fast, secure, and entirely in your browser.
No installation, no signup. Results in milliseconds.
A JSON to Go converter reads a sample of JSON and writes the Go struct definitions that describe its shape, complete with the json struct tags Go's encoding/json package uses to marshal and unmarshal. Instead of hand-writing a struct for every API response, you paste the response and get a typed definition you can drop into your package.
Go needs a concrete type to unmarshal JSON into, and writing those types by hand for a large payload is slow and easy to get wrong, especially the json tags that map exported fields back to their lowercase keys. Generating them from a real sample means the tags and types match the data exactly.
[]string, []Item).These are the inference rules the converter applies so the output is predictable.
| JSON | Becomes in Go |
|---|---|
Object { } | A struct with one field per key. |
| Nested object | Its own named struct, referenced from the parent field. |
Array [ ] | A slice such as []string or []Item. |
| Whole number | int64. |
| Decimal number | float64. |
| string / boolean | string / bool. |
| null (with a value) | A pointer such as *int64, so nil is representable. |
| null only / mixed types | interface{} (or []interface{} for a mixed array). |
Every field gets a json tag using the original key, so UserID int64 `json:"userId"` round-trips correctly. When you paste an array of objects, a key missing from some items is marked optional with ,omitempty, and a field that is sometimes null becomes a pointer so nil is representable. Validate the JSON first with the JSON parser if it will not convert, or tidy it in the JSON formatter.
interface{}A field that is only ever null, an empty array, or holds more than one unrelated type has no single concrete Go type, so it falls back to interface{}. Paste a representative sample with those fields populated to get precise types, and prefer giving an array of several records so optional fields are detected. For a deeply nested payload, expanding it in the JSON viewer first helps you confirm the shape.
See how a nested object with an array of items becomes clean, tagged Go structs.
Notice three things: items became its own Item struct and a slice, Qty got ,omitempty because the second item omits it, and coupon is interface{} because the sample only ever shows null. For the step-by-step reasoning, see our guide on converting JSON to Go structs.
Typed structs from real data, in seconds.
Everything developers ask about generating Go structs from JSON.
json:"userId" using the original JSON key, so marshaling and unmarshaling round-trip correctly even though Go field names are exported in PascalCase.int64 and numbers with a decimal point become float64. If a field holds both across the sample, it widens to float64 so every value fits.,omitempty in its tag. A field that is sometimes null and sometimes a value becomes a pointer, such as *int64, so nil is representable.[]string or []Item, with the element type inferred from the items.interface{} (or []interface{} for a mixed array).gofmt or goimports afterwards keeps the file consistent with the rest of your project.Hands-on articles from our blog.
All free, all browser-based, no signup required.