JSON to Go Struct Generator
Paste your JSON and instantly get Go structs with json tags, proper naming conventions, and nested type definitions. Everything runs in your browser — no data leaves your device.
JSON to Code Generator
Generate typed code from JSON in 8 languages — Go structs, Python dataclasses, Java/C#/Dart/Kotlin classes, Rust/Swift structs. Handles nested objects, arrays, and null values.
Supported Languages
| Language | Output Type | Serialization |
|---|---|---|
| Go | Structs with json tags | encoding/json |
| Python | Dataclasses with type hints | dataclasses |
| Java | Classes with getters/setters | Jackson / Gson |
| C# | Classes with JsonPropertyName | System.Text.Json |
| Dart | Classes with fromJson/toJson | dart:convert |
| Rust | Structs with serde derive | serde |
| Swift | Codable structs | Codable |
| Kotlin | Data classes with @Serializable | kotlinx.serialization |
How It Works
- Nested objects — each nested object becomes a separate named type/class/struct, referenced by the parent.
- Arrays — element types are inferred from the first item. Object arrays merge all items for complete field coverage.
- Numbers — integers and floats are detected automatically (e.g.,
int64vsfloat64in Go). - Null values— mapped to each language's nullable/optional type (e.g.,
Any?in Kotlin,Optionin Rust). - Naming conventions— field names follow each language's idiom (camelCase, snake_case, PascalCase) with JSON key annotations.
- Everything runs in your browser — no data is sent over the network.
Why Use Go Structs for JSON?
Go's encoding/json package uses struct tags to map JSON fields to Go fields. Writing these structs by hand is tedious and error-prone, especially for deeply nested JSON. This generator infers the correct Go types (string, int64, float64, bool) and creates properly tagged structs automatically.
// JSON input
// { "name": "Alice", "age": 30, "email": "alice@example.com" }
// Generated Go struct
type User struct {
Name string `json:"name"`
Age int `json:"age"`
Email string `json:"email"`
}
// Nested objects become separate structs
type Response struct {
Data User `json:"data"`
Status string `json:"status"`
Count int `json:"count"`
}How Go JSON Tags Work
Each struct field gets a `json:"fieldName"` tag that tells encoding/json how to marshal and unmarshal. Field names are converted to PascalCase (Go convention for exported fields), while the tag preserves the original JSON key. Nested objects become separate named structs.
Integer vs Float Detection
The generator distinguishes between int64 and float64 by checking if a number has a decimal part. Whole numbers like 42 become int64, while 3.14 becomes float64. Arrays infer their element type from the first item.
Frequently Asked Questions
Does this handle nested JSON objects?
Yes. Each nested object becomes a separate Go struct with a descriptive name based on the parent struct and field name. For example, a 'address' field inside 'User' generates a 'UserAddress' struct.
What about null values in JSON?
Null values are mapped to interface{} in Go, since the actual type cannot be determined from null alone. You may want to change these to pointers (*string, *int64) in your code.
Can I use this with JSON arrays?
Yes. If your root JSON is an array of objects, the generator merges all objects to produce the most complete struct definition.
Related Convert Tools
cURL to Code
Convert cURL commands to JavaScript, Python, Go, PHP, Ruby, and Java code instantly
JSON to CSV Converter
Convert JSON arrays to CSV with nested object flattening, column selection, and .csv download
TOML ↔ JSON/YAML
Convert between TOML, JSON, and YAML — perfect for Cargo.toml and pyproject.toml
Encode / Decode Multi-Tool
Base64, Base32, Hex, Binary, URL, and HTML encoding & decoding all in one tool