Turn a JSON sample into Go structs with json tags, int or float64, pointers and omitempty
Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.Paste a JSON sample and get Go struct types with json tags, ready for json.Unmarshal. Whole numbers become int, int64 past 2,147,483,647, and any decimal makes a field float64; a value that is sometimes null becomes a pointer, and keys missing from some objects get omitempty.
Paste a JSON sample, such as an API response, into the left box.
The Go types appear as you type: one struct per object, with json tags and Go-style names such as UserID.
Choose Inline nested structs or omitempty on every field if you want them, and set the root type name.
Press Copy, or Download to save a .go file, and add your package line.
Go decodes JSON into structs, and every field needs the right type and a json:"..." tag naming the key. This converter writes those types from a sample, so a 200-line API response becomes correct Go in one paste.
How types are chosen.
| JSON value | Go type |
|---|---|
| "text" | string |
| true / false | bool |
| 42 (whole numbers only) | int, or int64 beyond 32 bits |
| 4.5 (any decimal seen) | float64 |
| null, and also a type | a pointer, such as *string |
| only null, or mixed kinds | any |
| [ ... ] | a slice, such as []string |
| { ... } | a named struct, or an inline one |
Arrays of objects. All the objects of an array are merged into one struct, so a field that appears in only some of them is still there, with ,omitempty in its tag. Two objects with exactly the same keys and types share one type name.
Names. Keys become exported Go names in Go style: user_id becomes UserID, avatar_url becomes AvatarURL, using golint's list of initialisms. A key that starts with a digit gets an N in front; two keys that make the same name are numbered. A key with characters a tag cannot hold, such as a comma, is marked with a comment, because encoding/json would not match it.
Options. Inline nested structs writes one type with anonymous structs inside, which suits a one-off response. omitempty on every field suits structs you also marshal. The root type is called Root unless you name it.
Every output was checked by reading the Go back and decoding the sample with encoding/json's rules. Nothing you paste leaves the browser.
Paste a JSON sample into the converter and the Go struct appears beside it, with a json tag on every field and nested objects as their own types. Copy it into your package and decode with json.Unmarshal(data, &v), where v is a variable of the root type.
Use int when every sample value is a whole number and float64 when any value has a decimal part, because encoding/json refuses to put 4.5 into an int. The converter chooses per field, and picks int64 when a whole number is beyond 2,147,483,647.
A field seen both as null and as a value becomes a pointer, such as *string, so nil means null and an empty string stays different. A field that was only ever null becomes any, since the sample does not say what it would hold otherwise.
With omitempty, json.Marshal leaves the field out when it holds the zero value: an empty string, 0, false, nil or an empty slice. The converter adds it to keys missing from some objects of an array, and a switch adds it to every field.
Go style, checked by golint and most linters, writes initialisms in capitals: ID, URL, HTTP, API, JSON and about forty more. The json tag keeps the original key, user_id or userId, so decoding still matches the API exactly.
No. The conversion runs in your browser with no request to any server, and the JSON is not stored, so API responses holding tokens or personal data stay on your device. Close the tab and nothing remains.
Rates and rules change; check the source before you rely on a figure.
Still stuck? Ask about JSON to Go Struct Converter and anybody who knows can answer. No account needed.
Same job, other tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · JSON to YAML – Turn JSON into clean, readable YAML for configs · Query String Parser – Split a URL query string into a table of decoded parameters.