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
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.
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.
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.