JSON to Go Struct
Paste JSON and get Go struct types with json tags, ready for encoding/json.
How to use the JSON to Go Converter
- Paste JSONPaste an API response or any JSON object, or open a .json file.
- Set the optionsName the root struct, add omitempty to fields that can be missing or null, and choose pointers if you need to tell empty from missing.
- Copy the structsPaste them into your Go code and use json.Unmarshal to read the data.
Example
"is_active": true becomes IsActive bool `json:"is_active"`, and "orders": [...] becomes Orders []Order.
The sample produces 4 structs: Root, Address, Geo and Order. coupon is null in one order, so it gets ,omitempty.
Frequently asked questions
How are field names chosen?
Each JSON key becomes an exported Go name in PascalCase: is_active becomes IsActive and createdAt becomes CreatedAt. The json tag keeps the original key, so decoding still works.
Why int64 and float64?
Whole numbers become int64 and numbers with decimals become float64. If a field has both in the sample, float64 is used. Change them to int or float32 if you prefer.
How is time handled?
Dates stay as string, because Go’s time.Time only decodes RFC 3339 strings. Change the type to time.Time yourself if your API always uses that format.