← All Tools
JSON To Go Struct Converter🔒 100% local
Convert JSON to Go structs. Privacy-first, no server uploads, no tracking.
Reads a JSON object and writes Go struct declarations: a type Root struct block with one field per key, exported field names (first letter capitalised) and a json:"key" struct tag. Nested objects become their own structs above the parent, and an array of objects yields a slice of a struct named after the singular key. Field types follow the sample values - string, bool, int, float64, or *string with omitempty for a null.
How to use it
- Paste a JSON object into the input box.
- Hit Process and the Go source appears below the input.
- Copy the generated Go source into your package and adjust names or types as needed.
Worked example
{"id":1,"name":"Ada"}becomes// Go structs generated from JSON
type Root struct {
Id int `json:"id"`
Name string `json:"name"`
}
// Tip: go run with encoding/json Unmarshal; field names are exported (capitalized) per Go convention.Fields are space-padded into columns. Id, not ID - Go initialisms are not applied.
When to use it
- You have one real response body and want the struct definitions for encoding/json to Unmarshal into.
- Sketching the shape of a webhook payload before writing the handler.
- Turning a saved JSON fixture into Go types so a test can decode it.
What it does not do
- Types are inferred from a single sample, so an integer sample becomes int and a decimal becomes float64; 64-bit IDs, money and timestamps are better typed by hand.
- A null value becomes *string with omitempty, which guesses the type from nothing; a null object or array similarly loses its shape.
- Only the first element of an array is inspected for its struct shape, and an empty array becomes []any. Punctuation in keys is stripped from the field name (user-id becomes UserId) while the tag keeps the original key.