GOLANG · LIVE

JSON → Go Struct

Paste any JSON and instantly generate Go struct definitions with correct types, json tags, nested structs and slice support.

Options

JSON Input

Waiting for input

Go Output

Go structs appear here

Examples

JSON to Go struct conversion

When building Go applications that consume JSON APIs, you need struct definitions that match the JSON shape. Manually writing these is tedious and error-prone. This tool recursively analyzes your JSON and generates idiomatic Go structs with proper types, field names in PascalCase, and json struct tags with the original key names.

Type mappings

JSON string → string, JSON number with decimal → float64, JSON integer → int, JSON boolean → bool, JSON null → interface{} (or pointer with opt), JSON object → named struct, JSON array → slice.

What is omitempty?

The omitempty option in a json tag tells Go's json.Marshal to omit the field from output if it has the zero value (empty string, 0, false, nil). This is useful for optional fields in API requests.

When should I use pointer types?

Use pointer types (*string, *int) when a field can be null in JSON. A nil pointer marshals to JSON null, while a non-pointer with omitempty is omitted entirely. Pointers allow distinguishing between "field absent" and "field is zero value".