JSON to Go Struct Converter
Convert JSON to Go structs online with json tags, omitempty, pointer types for optional fields and unmarshal helpers. Free, instant and private in your browser.
π Runs entirely in your browser β nothing is uploadedGenerate Go structs from JSON
Writing Go structs by hand for a large API response is slow and error-prone. This JSON to Go converter does it instantly: paste a JSON sample and it generates exported struct types with properly cased field names and json struct tags that map each field back to its original key. Nested objects become separate named structs, arrays become slices, integers and floats are distinguished as int64 and float64, and ISO 8601 timestamps are recognised as time.Time. The output is ready for encoding/json without further editing.
The tool is powered by quicktype, which looks at every element of every array before choosing a type. If one item in a list carries a field the others lack, that field becomes a pointer so the zero value and the missing value stay distinguishable β a detail that single-pass converters often get wrong.
Options that matter in Go
Set the package name so the file compiles where you drop it. Enable omitempty when you also marshal these structs back to JSON and want absent optional fields to stay absent. By default the generator adds small Unmarshalβ¦ and Marshal helper functions around the root type; tick Structs only if you prefer to call json.Unmarshal yourself and just need the types. Rename the root struct from Root to the domain name you want β for example Repository or WebhookEvent.
Getting the best result
Feed the converter a representative sample: an array with several elements, optional fields filled in, and nested objects populated rather than empty. Empty arrays and null values give the inference nothing to work with and fall back to interface{}. After pasting the code, run gofmt, review numeric types where the sample might not show the full range, and replace generic strings with custom types where your API documents fixed values. Because all processing happens in your browser, internal or customer data never leaves your machine.
How to use
- Paste JSONPaste an API response or any JSON document, or load the sample.
- Pick optionsSet the root struct name and package, and decide on omitempty and helpers.
- Copy the structsCopy the Go code or download a .go file and run gofmt as usual.
Frequently asked questions
Does it add json struct tags?
`json:"key"` tag that preserves the original JSON key, and you can add ,omitempty to optional fields with one checkbox.How are optional and null fields handled?
*string, so you can tell an absent value from a zero value.What do the helper functions do?
UnmarshalRoot and Marshal helpers. Tick Structs only to get just the type declarations.