JSON to Go Struct Converter
Paste a JSON object and get ready-to-use Go structs with proper field names, types, and `json:"..."` tags for `encoding/json`.
Last updated: May 27, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is JSON to Go Struct Converter?
Go's `encoding/json` package uses struct tags to map JSON keys onto exported struct fields. Writing those structs by hand for a large API response is repetitive: each field needs an exported name (Go convention), a Go type, and a `json:"original_key"` tag if the JSON key differs from the Go field name.
This tool reads a JSON example and emits the matching struct hierarchy. Integers within int range become `int`, larger ones become `int64`, decimals become `float64`, and so on. Arrays become slices (`[]T`). Nested objects produce nested struct types. Field names are converted to Go's PascalCase, with Go-style common initialisms (ID, URL, API, HTTP) preserved in uppercase. Tabs align the columns, matching gofmt output.
How to Use JSON to Go Struct Converter
Paste a JSON object (root must be an object).
Set the root struct name and package name.
Toggle json tags and pointer types for nested structs.
Copy the generated structs into your project.
Common Use Cases
- Bootstrapping Go structs for a JSON API client.
- Generating types for a service consuming JSON config.
- Converting an OpenAPI example to typed Go structs.
- Producing model types for sqlx or GORM with JSON columns.
Example Input and Output
A flat JSON object becomes a Go struct with json tags.
{ "userId": 42, "name": "Alice", "active": true }type Root struct {
UserID int `json:"userId"`
Name string `json:"name"`
Active bool `json:"active"`
}Privacy
All conversion happens in your browser. No JSON is sent to a server.
Go formatting
The output uses tab indentation and column alignment matching gofmt. You can copy and paste without re-running gofmt.

