Dad’s Data formats tools

JSON → Go

Generate Go struct types from JSON — nested structs, JSON tags, and pointer types for nullable fields. 100% local.

JSON Input
Root struct name
Go Output
Paste JSON to generate Go structs.

How Struct Inference Works

The inferrer walks your JSON and produces idiomatic Go structs. Each JSON object becomes a named struct with exported PascalCase field names and json:"..." struct tags preserving the original key name. Nested objects are hoisted to separate named structs, keeping the generated code flat and readable. Null values produce pointer fields (*T) to distinguish between a missing value and a zero value.

Input
{
  "user": {
    "id": 1,
    "name": "Alice",
    "email": "[email protected]",
    "score": 9.5,
    "tags": ["go", "backend"],
    "address": {
      "city": "Berlin",
      "country": "DE"
    },
    "deleted_at": null
  },
  "total": 42,
  "active": true
}
Output
type Root struct {
	User   User  `json:"user"`
	Total  int64 `json:"total"`
	Active bool  `json:"active"`
}

type User struct {
	ID        int64    `json:"id"`
	Name      string   `json:"name"`
	Email     string   `json:"email"`
	Score     float64  `json:"score"`
	Tags      []string `json:"tags"`
	Address   Address  `json:"address"`
	DeletedAt *interface{} `json:"deleted_at"`
}

type Address struct {
	City    string `json:"city"`
	Country string `json:"country"`
}

Type Mapping

JSON valueGo typeNotes
"string"stringAny string value
42 (integer)int64No decimal point and within int64 range
3.14 (decimal)float64Number with decimal point or beyond int64
true / falseboolBoolean literal
null*T (pointer)Nullable field — pointer allows distinguishing nil from zero value
["a", "b"][]stringHomogeneous array infers element type
[1, "a"][]interface{}Mixed-type array falls back to interface{}
{} or { ... }Named structNested objects become separate named structs
[] (empty)[]interface{}Empty array — element type cannot be inferred
Tip: Field names in Go structs are always PascalCase exports. The original JSON key is preserved in the struct tag: json:"user_id". The encoding/json package uses these tags to correctly marshal and unmarshal your data.

Limitations to Know

Warning: Inference is based on the sample you provide. If a field is null in your sample but carries a real type in production data, the generated pointer field will need to be updated — for example from *interface{} to *string. Always review the output against your actual API contract before using it in production code.

Try It

Interactive — edit the input to see the output update
Try it
Result

Frequently Asked Questions

Your files stay on your computer. Dad promised.

Data formats tools

Search the Data formats tools