Struct name:
JSON Input 0 B
Ready
0 chars
Go Output 0 B
Go structs will appear here...
0 chars
Features

Why use this generator

JSON tags

Every field gets a json:"name" tag, so the struct works directly with encoding/json. No additional configuration needed.

Type mapping

JSON strings become string, integers become int64, floats become float64, booleans become bool, null becomes interface{}. Arrays become slices []T.

Nested structs

Each nested object becomes its own struct. Struct names are derived from field names, capitalized to follow Go conventions.

How it works

Conversion explained

1. Parse JSON

Input is parsed into a JavaScript value. The struct structure is determined by walking the value tree.

2. Collect structs

For each object, a Go struct is generated with fields, types, and JSON tags. The struct name is derived from the parent field name, capitalized.

3. Emit Go

Structs are emitted with proper Go formatting: tabs for indentation, exported field names (capitalized), and JSON tags in backticks.

FAQ

JSON to Go Struct Generator — frequently asked questions

Is this compatible with encoding/json?

Yes — the generated structs include json:"fieldname" tags, so they work directly with json.Marshal and json.Unmarshal.

Why use int64 instead of int?

Go's int is platform-dependent (32 or 64 bits). int64 is explicit and handles large JSON integers safely.

Are nested structs supported?

Yes — each nested object becomes its own struct. The struct name is derived from the field name, capitalized to make it exported.

How are nullable fields handled?

Currently, nullable fields use interface{}. For proper nullable typing, edit the output to use a pointer type (*string, *int64).