JSON to Go — Generate Go Structs from JSON
Paste JSON and instantly get typed Go structs with json tags, nested structs, and slices. The converter infers correct Go types (int64, float64, bool, string), so the output drops straight into encoding/json. Everything runs locally in your browser.
This JSON to Go converter turns any JSON sample into ready-to-use Go struct definitions. It infers a Go type for every field, generates a separate named struct for each nested object, and adds a json:"..." tag with the original key so encoding/json marshals and unmarshals your data correctly. It runs entirely in your browser, so your JSON never leaves your machine.
What this JSON to Go converter produces
- Exported Go structs with a field for every JSON key.
json:"key"struct tags that preserve the original JSON names.- Nested structs for nested objects, and Go slices (
[]T) for arrays. - Inferred Go types:
string,int64,float64,bool, andinterface{}for unknown or null values.
How to convert JSON to Go structs
- Paste your JSON into the left editor (or click Load Sample).
- Click Generate Models, or enable Auto-generate on change.
- Copy or download the Go structs from the right editor.
Example: JSON to Go struct
Input:
{ "id": 7, "name": "Ava", "active": true, "roles": ["admin"] }
Generated Go:
package main
type Root struct {
Id int64 `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
Roles []string `json:"roles"`
}
JSON to Go type mapping
- JSON string →
string - JSON integer →
int64 - JSON number (float) →
float64 - JSON boolean →
bool - JSON array →
[]T(slice of the element type) - JSON object → a named nested
struct - JSON null / unknown →
interface{}
Field names are exported (capitalized) so encoding/json can access them, while the json tag keeps the original lowercase or snake_case key from your data.
FAQs
Does it add json tags?
Yes. Every field gets a json:"key" tag using the original JSON key, so marshaling and unmarshaling round-trip correctly.
How are nested objects and arrays handled?
Nested objects become their own named structs; arrays become slices such as []string or []Item.
What happens with null values?
Null or unknown values map to interface{}. You can change the field type by hand if you know the concrete type.
Is my data uploaded?
No. Everything runs locally in your browser.
Related tools: JSON to TypeScript, JSON to Java POJO, JSON to C#, JSON Validator