JSON to Go Struct
Generate Go structs from JSON with named nested types, pointer options, JSON or DB tags and an observed field map.
Generate Go Structs for Inventory JSON
Leave the pointer blank to use the full document. Use /items or /items/0 to pick a nested value.
JSON to Go Struct: how to use it
- Paste sample JSON, select a UTF-8 file or load the inventory example. Leave Root JSON Pointer blank or select part of the document with a pointer such as /items.
- Set a model name and Go package. Choose JSON tags, JSON and DB tags, or no tags. Select how missing or nullable fields become pointers.
- Generate Go, check the field mapping and review notes, then download models.go or copy the source.
Limits and notes
Uses up to 4,194,304 input and output characters, a 4 MiB UTF-8 file, 128 nested levels and 500,000 JSON tokens. Duplicate keys are rejected. Processing stays on this device.
How your privacy works →JSON to Go Struct: common questions
Will a large JSON integer stay exact in Go?
Integer tokens inside the signed 64-bit range use int64. The generator selects json.Number for larger integers and for numbers it identifies outside its float precision range.
What happens when an array has mixed element types?
The converter emits a slice of json.RawMessage for mixed element kinds. Each raw entry keeps its JSON bytes for later decoding.
Can pointers tell a missing field from explicit null?
Go's encoding/json sets a pointer to nil for explicit null and leaves a fresh struct's missing pointer nil. Check the input key separately when you need to tell the two cases apart.