JSON to Go Struct

Generate idiomatic Go structs from JSON. Proper json tags, omitempty, and pointer types for nullable fields. Runs in your browser.

ROOT
JSON INPUTsample payload
GO OUTPUT
// Go structs appear here

From JSON sample to typed Go struct

Consuming a JSON API in Go means writing structs that match the payload, plus the right json tags for any non-Go field naming. Hand-writing those for a 30-field API is the kind of mechanical work that should be a single paste.

Common Go initialisms (ID, URL, API) are detected and capitalized correctly — user_id becomes UserID, not UserId, matching gofmt and golint conventions. Nested objects become their own struct types defined alongside the root.

encoding/json native

Output ready for json.Unmarshal(data, &v). No third-party serializer required; the standard library does it all.

Privacy first

Generation runs locally. Paste production JSON without leaking — nothing is uploaded.

Common questions

What does this generate?
Idiomatic Go structs with json struct tags matching the original key names. Fields are exported (capitalized), nested objects become nested struct types, arrays become Go slices.
Why are field names capitalized?
Go only exports identifiers that start with an uppercase letter. encoding/json can only marshal and unmarshal exported fields, so the convention is to capitalize the Go name and use a struct tag to keep the original JSON key.
What about omitempty?
Add the omitempty option (toggle in the toolbar) and the marshaller will skip zero values when serializing back to JSON. Useful for API payloads where you want to omit empty strings, zero numbers, or nil pointers.
How are pointers handled?
Fields that are null in any sample are emitted as pointer types (*string, *int) so they can distinguish "missing" from "zero". Toggle off if you prefer plain types — null becomes the zero value for the field.
What number type does it use?
JSON numbers without a decimal become int64. Numbers with a decimal become float64. JSON has only one numeric type but Go distinguishes — this is the safest mapping for round-tripping.
Is my data private?
Yes. Generation runs locally in this browser tab. Paste production payloads without exposure.