JSON to Go Struct

Generates a minimal, readable Go struct from a JSON sample, with json tags preserved and a nested struct for every nested object.

Private by architecture: All processing is 100% client-side memory. Your data never leaves this browser tab.
JSON input
0 lines · 0 charsJSON
Go output
Ctrl/Cmd+Shift+C
0 charsGo

Example

{"id": 1, "name": "Ada", "address": {"city": "Lagos"}}

produces:

type Root struct {
	Id int64 `json:"id"`
	Name string `json:"name"`
	Address RootAddress `json:"address"`
}

type RootAddress struct {
	City string `json:"city"`
}

FAQ

Can I convert Go structs back to JSON?
Yes! Click the ⇌ swap button or toggle the Direction dropdown to generate mock JSON from any Go struct definition.
How are numbers typed?
A whole number becomes int64; a number with a fractional part becomes float64. This is inferred from the sample, not guaranteed for every possible value the field could hold.
What happens to a field observed as null?
It becomes any, since a single null sample carries no concrete type information.
Are invalid or reserved field names handled?
Yes. Keys are converted to exported PascalCase Go identifiers; the original key is preserved exactly in the json tag.
Is the generated code executed?
No. It is text output only, never compiled or run.