🐹JSON to Go Struct Generator

Turn JSON into Go structs with json tags

How a Go type is picked from a JSON value

JSON valueGo typeNote
StringstringDirect
BooleanboolDirect
Number without a decimal pointint or int64Your choice
Number with a decimal pointfloat64Direct
ObjectNested structType named from the key
Array[]ElementTypeElements merged first
nullCannot inferany or interface{}
Empty arrayCannot inferLeft as []any
Array of mixed typesCannot inferLeft as any

A null, an empty array and an array of mixed types carry no type information, so nothing is guessed and each location is listed by path under the result. Field names are capitalised so they are exported, which also keeps them clear of Go keywords. Capitalising initialisms is Go community practice rather than a rule set by the language.

You Might Also Need

Pulling Go structs out of a JSON response

Paste an API response and you get Go structs with field names, types and json tags attached. Nested objects become types of their own, and an array of objects is inferred from every element merged together, so a field that appears in only one element is not lost. The output is spaced to match what gofmt produces.

Types come from the shape of the values. A number without a decimal point becomes int or int64 as you choose, and one with a decimal point becomes float64. The hard cases are null, empty arrays and arrays of mixed types. None of the three carries type information, so nothing is guessed: they are left as any or interface{} and each location is listed by path. As of October 2026 leaving them visible is treated as safer than filling them in with a guess.

Field names are capitalised so they are exported, and a repeated name gets a number appended. Capitalising initialisms is Go community practice, which is why it is a choice rather than a default rule. This page handles Go only and does not produce model classes for other languages.

Frequently Asked Questions

Why is a null field left untyped?

Because null says nothing about what the value would have been. In an array of objects, though, where one element is null and another carries a value, that value sets the type and the field is marked as a pointer.

Should I choose int or int64?

JSON numbers have no range limit, so int64 is the safer pick for responses that might carry large values, especially for timestamps or identifiers with many digits.

Why are pointers and omitempty used together?

A pointer is what keeps an absent value distinct from zero or an empty string, and omitempty is what drops the field from the JSON when it is empty. Both are needed for the round trip to line up.