JSON to Go Struct

Generate Go structs with json tags from a JSON sample.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

Generate Go structs from JSON

Decoding JSON in Go means defining a matching struct with the right field types and json:"..." tags by hand — tedious and error-prone for nested payloads. This tool infers typed Go structs from a representative JSON sample so you can paste them straight into your project.

How it works

The generator walks the sample and maps each value to a Go type, building nested structs as it goes:

JSONGo type
integral numberint64
fractional numberfloat64
mixed numeric array[]float64
stringstring
booleanbool
objectits own exported struct (pointer)
array of T[]T
mixed array[]interface{}

Field names are PascalCased, with common initialisms like ID and URL capitalised the way Go’s style guide expects, and every field gets a json:"originalKey" tag.

Example

This JSON:

{ "id": 7, "user": { "name": "Sam" } }

generates:

type Root struct {
	ID   int64 `json:"id"`
	User *User `json:"user"`
}

type User struct {
	Name string `json:"name"`
}

Because the types are inferred from one sample, treat the output as a strong starting point. All inference happens in your browser — your JSON is never uploaded or stored.

Ad placeholder (rectangle)