JSON to Go
Paste a JSON sample and get Go struct definitions — nested objects, arrays, and json struct tags generated automatically. Runs entirely in your browser.
Type mapping
| JSON value | Go type |
|---|---|
| "hello" | string |
| 42 | int |
| 3.14 | float64 |
| true / false | bool |
| null | interface{} |
| ["a", "b"] | []string |
| [{"id": 1}] | []TypeName |
| {"key": val} | type TypeName struct { ... } |
| [] | []interface{} |
Frequently Asked Questions
How does the type inference work?+
The converter parses the JSON and walks each value recursively. Strings become string, whole numbers become int, decimals become float64, booleans become bool, null and unknown values become interface{}, arrays produce []T where T is inferred from the first element, and objects become named structs with exported (capitalized) field names and matching json tags.
Why do field names get capitalized?+
Go only exports struct fields whose names start with an uppercase letter — lowercase fields are unexported and invisible to the encoding/json package and other packages. The converter capitalizes each field name and adds a `json:"original_name"` struct tag so the struct still marshals and unmarshals using the original JSON key.
What if my array contains items of different types?+
The converter infers the element type from the first array element. For a heterogeneous array like [1, "foo", null], the output will be []int based on the first element. You may need to change the slice type to []interface{} and perform manual type assertions for genuinely mixed-type arrays.
Is my JSON sent to a server?+
No. All conversion runs entirely in your browser using JavaScript. Your JSON never leaves your device.
Related Tools
How to use
- Paste a JSON sample — Go struct definitions generate instantly.
- Nested objects become separate
structdeclarations withjsontags. - Copy the output and paste it into your Go project.
- Rename structs and adjust field types as needed for your data model.