JSON → Go Struct
Paste a JSON sample, get Go struct definitions with JSON tags. Pointer-for-nullable, omitempty tags, configurable package and top-level type name.
Paste JSON.
How to generate Go structs
- Paste your JSON sample.
- Configure:
- Top-level type name (default
Root). - Package (default
main). - Pointer for nullable — on (
*stringfor optional) / off. - JSON tag style —
omitemptyon / off. - Inline anonymous structs vs Named subtypes.
- Top-level type name (default
- Output appears below. Copy or Download as
.go.
FAQ
Should I use omitempty or pointers?
Both — pointers + omitempty is the most flexible combo: zero-value fields are serialized for value types (with omitempty they'd vanish), and pointer fields with omitempty only serialize when set.
Why are my numbers int64?
JSON numbers are double-precision floats — the tool picks int64 for whole numbers, float64 otherwise. If your numbers fit in int32, hand-edit.
Will it work offline?
Yes.