JSON to Go
Convert JSON into idiomatic Go structs complete with json struct tags. Integers map to int, decimals to float64, booleans to bool, and nested objects become named structs. Runs in your browser.
About JSON to Go
Generates Go structs with json struct tags from sample JSON. Integers become int, decimals become float64, booleans become bool, and nested objects become named structs. Beautify the source first with the JSON Formatter, or convert to other languages usingJSON to TypeScript andJSON to C#.
Secure & Private Client-Side
This tool runs entirely in your browser. No data is sent to any server, ensuring your information remains private and secure.
About JSON to Go
Convert JSON into idiomatic Go structs complete with json struct tags. Integers map to int, decimals to float64, booleans to bool, and nested objects become named structs. Runs in your browser.
Frequently Asked Questions
Why are json struct tags included? expand_more
Go encoding/json uses struct field names by default, which often do not match JSON keys. The json:"key" tag ensures correct marshaling and unmarshaling.
How are arrays and null handled? expand_more
Empty arrays become []interface{}, non-empty arrays derive their element type, and JSON null maps to interface{} so it can hold any value.
Can I generate types for other languages? expand_more
Yes. Use [JSON to TypeScript](/tools/json-to-typescript/) or [JSON to C#](/tools/json-to-csharp/).
Should I run gofmt on the output? expand_more
Yes. Running gofmt or goimports after pasting ensures the code matches Go formatting conventions.
Is my data private? expand_more
Yes. Everything runs client-side; your JSON never leaves the browser.
Common Use Cases
- Go Services: Generate struct definitions for unmarshaling JSON API responses.
- Config Files: Build Go structs that match JSON configuration files.
- Webhooks: Quickly model inbound webhook payloads as Go types.
- Database Rows: Convert sample JSON rows into structs for your data layer.