JSON → Go
Paste any JSON and get ready-to-use Go structs, with json tags, nested types, slices, and exported field names. Runs entirely in your browser.
JSON into Go structs, instantly
Paste a JSON object and this tool walks it to produce matching Go struct definitions, complete
with json:"..." tags so unmarshalling round-trips your original keys. Nested objects become their
own named structs, arrays become slices, and field names are converted to exported PascalCase
with Go’s common initialisms handled, id → ID, url → URL,
api → API.
How types are inferred
- Numbers become
intwhen every sample is whole, otherwisefloat64. - Arrays become a slice of the merged element type; arrays of objects merge their keys.
- Mixed or null-only values fall back to
interfacerather than guessing. - Keys missing from some objects in an array become
*pointerfields (optional), so a zero value is distinguishable from absent.
FAQ
Why are some fields pointers?
When a key appears in only some objects of an array, it’s emitted as a pointer with omitempty, so an absent value is nil rather than a misleading zero.
Does it handle nested JSON?
Yes, each distinct object shape becomes its own named struct, referenced from the parent. Nesting is unlimited.
Is my JSON uploaded?
No. It’s parsed in your browser, so it’s safe to paste private payloads and it works offline.
Related
Prefer TypeScript? Use JSON → TypeScript. Coming from a spreadsheet? See CSV ⇄ JSON.