JSON to Go Struct
Generate Go structs with json tags from a JSON sample, with nested types, pointers for nullable fields and Go-style initialisms.
Free · No sign-up · Your inputs stay in your browser
Input
Generate Go structs from JSON
Output
Go
478 characters
Whole numbers become int64 and fractions float64; a nullable value becomes a pointer, so encoding/json can tell null from zero. Mixed-type arrays become []any. Initialisms follow Go style (ID, URL).
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Why pointers for nullable fields
Go has no null for an int or a string: the zero value is 0 or "". A pointer field is nil when the JSON had null or omitted the key, so the two cases can be told apart from a real zero. The encoding/json documentation describes how tags, omitempty and pointers interact.
Numbers
Decoding into any turns every JSON number into float64, which loses precision above 253. Typed fields avoid that. For IDs that may exceed it, the field tag json:",string" reads a quoted number, and json.Decoder.UseNumber keeps numbers as text.