JSON to Go
Paste JSON and get ready-to-use Go structs with json tags. Nested objects become their own structs and the original field names are preserved in the tags. Everything runs locally in your browser.
Generate Go structs from JSON
Writing Go structs by hand to match an API payload means getting every field name, type and json tag exactly right — and Go will silently leave fields at their zero value if a tag is wrong. Paste a real JSON sample and this tool generates the structs for you: exported field names, correct json tags that preserve the original keys, nested objects broken out into their own structs, and slices for arrays. The output is ready to paste into a .go file and use with encoding/json.
How to use it
- Paste a JSON object into the input box.
- Set the Root name for the top-level struct (defaults to
Root). - Copy the generated Go on the right into your project.
A worked example
This JSON:
{ "id": 10, "name": "Ada Lovelace", "active": true }produces:
type Root struct {
ID float64 `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
}Adjust float64 to int for the id if your API guarantees integers — JSON cannot distinguish the two, so the generator picks the safe default.
When you would reach for it
Building a Go client for a REST API, modelling a webhook payload, or decoding a config file. For other languages, see JSON to TypeScript and JSON to Python; to validate the shape at runtime, generate a JSON Schema too.
Privacy
Code generation runs entirely in your browser and works offline once loaded. Your JSON is never uploaded or stored, so pasting a real API response with sensitive fields is safe.
Frequently asked questions
Why are numbers typed as float64?
JSON has a single number type, so every numeric field maps to float64 by default. Change fields to int or int64 where you know the value is a whole number.
What are the json tags for?
The json:"field" tags let encoding/json marshal and unmarshal using the exact original key names, even though Go struct fields must be exported (capitalized). Without them, user_id in your JSON would not map to a UserId field.
How are nested objects handled?
Each nested object becomes its own named struct and the parent references it by type, so you get clean, reusable definitions instead of deeply inlined anonymous structs.
How are arrays typed?
An array of objects becomes []SomeStruct and an array of scalars becomes a slice of that type, such as []string. An empty array becomes []interface{} since its element type cannot be inferred.
What about field name casing?
Go requires exported fields to start with a capital letter, so first_name becomes FirstName while the original key is preserved in the struct tag for correct (de)serialization.
Does my JSON get uploaded?
No. Structs are generated entirely in your browser — nothing is sent to a server.