What is JSON → Go Struct?
Generate Go structs from JSON data with proper json struct tags.
Nested objects become their own struct types, with a JSON tag on every field. Output updates as you type, and everything runs in your browser.
Features
- Generate Go structs from JSON
- JSON struct tags with field mappings
- omitempty tag support
- Nested struct generation
- Pointer types for nullable fields
- Copy generated code to clipboard
How to use JSON → Go Struct
- Paste your JSON. Enter a sample JSON object.
- Generate Go structs. Get Go structs with proper json tags.
- Copy and use. Paste the generated structs into your Go project.
Examples
Generating Go structs
A small user record with a nested address, generated with the default settings.
Input
{
"id": 1,
"name": "Ada Lovelace",
"email": "ada@example.com",
"active": true,
"tags": ["admin", "dev"],
"address": { "city": "London", "zip": "EC1A" }
}Output
// Code generated from JSON Schema using quicktype. DO NOT EDIT.
// To parse and unparse this JSON data, add this code to your project and do:
//
// root, err := UnmarshalRoot(bytes)
// bytes, err = root.Marshal()
package main
import "encoding/json"
func UnmarshalRoot(data []byte) (Root, error) {
var r Root
err := json.Unmarshal(data, &r)
return r, err
}
func (r *Root) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type Root struct {
ID int64 `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Active bool `json:"active"`
Tags []string `json:"tags"`
Address Address `json:"address"`
}
type Address struct {
City string `json:"city"`
Zip string `json:"zip"`
}Frequently asked questions
What Go features are generated?
Structs with json tags, omitempty, pointer types for nullable fields, and nested structs.
Can I use this with Go modules?
Yes. Works with encoding/json, gorilla/mux, gin-gonic, and any Go project.
