JSON to Go Struct
Paste JSON and generate Go struct definitions with json tags; nested objects become named structs and arrays of objects become slices. Nothing is uploaded — generation is local.
JSON to Go Struct
Go talks to JSON through struct tags. Handwriting those structs is slow and error prone when the payload nests. This generator reads your JSON and writes the matching Go struct definitions, including a json tag for every field, named types for nested objects and slices for arrays of objects.
How it works
- JSON is parsed with the browser's native
JSON.parse; nothing leaves the page. - The top level becomes
type AutoGenerated struct { ... }(rename it in the box above). - Every field carries a
json:"key"tag; the optional toggle appends,omitempty. - Keys with separators become exported PascalCase names, for example
user_namebecomesUserName. - Nested objects become named structs derived from the parent key; arrays of objects become slices such as
[]Address. - Strings map to
string, booleans tobool, integers toint, other numbers tofloat64and null tointerface{}.
Frequently asked questions
What does this tool do?
It converts JSON into Go struct definitions, emitting a top-level struct with json tags on every field and named nested structs for nested objects.
Is my data uploaded?
No. Parsing and code generation run entirely in your browser; nothing is sent to a server.
How are JSON keys turned into Go names?
snake_case, kebab-case and dotted keys are split into words and converted to exported PascalCase names, while the original key is preserved in the json tag.
How are nested objects and arrays handled?
A nested object becomes its own named struct, and an array of objects becomes a slice such as []Child, with element type names singularised where sensible.
Which Go types are used?
Strings map to string, booleans to bool, numbers to int when every value is integral and float64 otherwise, null to interface{}, and mixed values to interface{}.
Is the generated code ready to use?
It is standard Go you can paste into a .go file; review the chosen types against your API or JSON Schema before shipping.
Related: tidy the payload first with the JSON formatter, convert it with the JSON to XML converter, or browse every browser-only tool on the all tools page.