RealJSON
Try now

JSON to Go Struct Converter

Paste any JSON and get Go structs instantly — nested types, arrays and optional fields included.

Root type name

Package

JSON input

Go structs

 

In short: A JSON to Go converter reads a JSON document and writes the matching Go struct definitions, complete with json:"…" tags. Nested objects become their own named structs, arrays become slices and nullable or missing fields become pointers with omitempty.

JSON to Go Converter

Writing Go structs by hand for every API response is slow and easy to get wrong. This tool infers the types from real data: it merges every item of an array, so a field that is missing from some items is marked optional instead of being silently dropped.

Paste the struct into your package and decode with json.Unmarshal(data, &v). Everything runs locally in your browser — safe for private payloads.

How the Conversion Works

Type mapping

strings → string, whole numbers → int64, decimals → float64, booleans → bool, arrays → []T, objects → named structs and unknown values → interface{}.

Null and optional fields

Fields that are null or missing from some array items become pointers (*string) and get omitempty so encoding/json can tell "absent" from "zero".

Naming

Keys are converted to exported PascalCase field names (first-name → FirstName) and the original key is preserved in the struct tag.

Frequently Asked Questions

How do I convert JSON to Go?

Paste your JSON, set a root type name, and Go structs are generated instantly. Copy the result or download it as a .go file.

How are nested objects and arrays converted to Go?

Each nested object becomes its own named type and arrays use the element type inferred from all of their items, so arrays of objects are fully typed.

How are null and missing values handled?

Fields that are null or missing from some array items become pointers (*string) and get omitempty so encoding/json can tell "absent" from "zero".

How do I unmarshal JSON into the generated Go struct?

Copy the structs into your package, then call json.Unmarshal(data, &root) where root is the generated root type. The json tags map each key to its field, including keys that are not valid Go identifiers.

Is my JSON sent to a server to generate the Go structs?

No. Generation runs entirely in your browser — your JSON never leaves your device.

Related Tools

JSON to TypeScript · JSON to JSON Schema · JSON Validator · JSON Formatter

Browse all free JSON tools →

Related tools