Stop Typing Struct Definitions by Hand
You’ve got a third-party API that returns a 20-field JSON object with three levels of nesting. You need Go structs to unmarshal it. Writing them manually means staring at the JSON, counting fields, getting the types right, capitalizing every field name to PascalCase, adding json:"original_name" tags so encoding/json knows what to map… it’s 15 minutes of tedious, error-prone typing.
Paste the JSON here. You get Go structs with correct type mappings (string, int64, float64, bool, interface{} for values that are always null or mix kinds), exported PascalCase field names, json struct tags preserving the original keys, and separate named structs for nested objects.
type Root struct {
UserName string `json:"user_name"`
Age int64 `json:"age"`
IsActive bool `json:"is_active"`
}
Copy, paste into your Go file, and you’re coding in 30 seconds instead of 15 minutes.
After You Generate
The output is a starting point. You’ll probably want to:
- Add
bson,db, oryamlstruct tags if you’re using MongoDB, GORM, or Viper - Replace
interface{}with concrete types where you know the actual schema - Add validation tags from libraries like
go-playground/validator - Rename the root struct from
Rootto something meaningful likeUserResponse
Arrays are read in full, not just the first element. A key missing from some items gets omitempty and a pointer type, so “absent” and “zero” stay distinguishable; a value that’s sometimes null becomes a pointer too. Integers mixed with decimals become float64, integers too large for int64 become json.Number so no digits are lost, and keys that can’t be written in a struct tag (a comma or quote in the name) are flagged with a comment instead of being mapped wrong.
Where This Saves Real Time
Consuming external APIs. You’re integrating with a payment provider, a weather service, or a social media API. Their docs show JSON examples. Paste the example, get your structs, and start writing your HTTP client.
Config file parsing. Your Go app reads a JSON config file. Paste a sample config and generate the struct that json.Unmarshal needs.
Microservice contracts. Your gRPC service receives JSON-encoded payloads. Generate request and response structs from sample payloads.
For TypeScript interfaces from the same JSON, the JSON to TypeScript converter handles that. For Python dataclasses, use the JSON to Python Dataclass tool. All three share a similar flow — paste JSON, get typed code.
Everything runs in your browser. No data transmitted.