๐ Runs in your browser โ nothing is uploadedโ Free, no signup
JSON to Go Struct Converter
Paste JSON to generate Go structs with json tags. Nested objects become their own structs, optional fields get omitempty, and common initialisms like ID and URL are capitalised the Go way.
0 characters
Go structs
When should you use the JSON to Go?
- Decoding an API response in a Go service
- Creating types for a JSON config file
- Writing Go clients for third-party APIs
How to use the JSON to Go
- 1
Paste JSON
Paste a sample object or array โ the more complete the sample, the better the types.
- 2
Name the struct
Change Root to something meaningful like User or Response.
- 3
Choose options
Keep omitempty on optional fields and pointers for nullable fields, or turn them off.
- 4
Copy into your project
Copy the structs or download them as types.go.
Examples
Array items with an optional field
JSON
{
"id": 1,
"orders": [
{ "total": 9.5 },
{ "total": 20, "coupon": "SAVE" }
]
}Go
type Root struct {
ID int64 `json:"id"`
Orders []Order `json:"orders"`
}
type Order struct {
Total float64 `json:"total"`
Coupon string `json:"coupon,omitempty"`
}Common errors and how to fix them
A field is interface{}- The sample had only null for that field, or mixed types. Paste a sample where the field has a real value, or set the type by hand.
Numbers became float64- If any item has a decimal (like 15.5), the field becomes float64. Whole numbers everywhere give int64.
More from JSON Tools
Free tools that run in your browser โ no signup, nothing uploaded.
JSON Auto-Fixer & Formatter
Repair, validate, and beautify broken JSON (missing quotes, trailing commas).
JSON Validator & Linter
Check JSON syntax and see the exact line and column of every error.
JSON Viewer (Tree)
Explore JSON as a collapsible tree with search and click-to-copy paths.
JSON Editor
Edit JSON with live validation, a tree view, formatting and key sorting.
JSON Beautifier
Pretty-print and indent JSON for easy reading and debugging.
JSON Compare & Diff Tool
Find the difference between two JSON objects visually and quickly.
JSON Sorter (Sort Keys)
Sort JSON object keys alphabetically, including nested objects.
JSONPath Tester
Evaluate JSONPath expressions with filters and recursive queries.
JSON Schema Generator
Generate a JSON Schema from any sample JSON document.
JSON to Go FAQ
JSON keys are converted to exported PascalCase Go names, and common initialisms are uppercased โ user_id becomes UserID and avatarUrl becomes AvatarURL. The original key is kept in the json tag.
When a key is missing from some objects in an array, or is null. Untick the option if you don't want it.
Whole numbers become int64 and decimals become float64. If a field has both, it becomes float64.
Each nested object becomes its own named struct, which makes the code easier to read and reuse.
A pointer like *string lets you tell the difference between a missing or null value and an empty string.
No. Everything runs in your browser, so your JSON never leaves your device.
