Skip to content

JSON to Go Struct

Embed

Paste this where you want JSON to Go Struct on your site. Adjust the height to fit.

<iframe src="https://www.browserutils.dev/embed/json-to-go/" width="100%" height="500" frameborder="0" loading="lazy" title="JSON to Go Struct"></iframe>
<p style="font-size:12px;margin:4px 0 0"><a href="https://www.browserutils.dev/tools/json-to-go/">JSON to Go Struct</a> by BrowserUtils</p>

Generate Go structs from JSON data.Runs in this tab.

Next step

About JSON to Go Struct

Free online JSON to Go converter. Automatically generate Go struct definitions with proper types and JSON tags from sample data. It runs in your browser. Nothing is sent to a server.

Questions

How are JSON types mapped to Go types?
Strings map to string, numbers to float64 (or int if whole), booleans to bool, arrays to slices, and nested objects to nested structs with json tags for field mapping.
Does it generate proper JSON struct tags?
Yes, each struct field includes a json:"fieldName" tag matching the original JSON key name, ensuring correct serialization and deserialization.
Can I use the generated structs with encoding/json?
Yes, the generated structs are ready to use with Go standard library encoding/json package for both marshaling and unmarshaling JSON data.
How are nullable JSON fields handled in Go?
Fields that appear as null in the JSON are generated as pointer types (e.g., *string) so they can represent the absence of a value in Go.
Can I use this to generate Go structs from an API response?
Yes, paste a sample JSON response from any API and the tool will produce Go struct definitions ready to use with http client code and json.Unmarshal.
Does the JSON to Go converter handle nested arrays?
Yes, nested arrays of objects generate their own struct types, and the parent field becomes a slice of that struct type (e.g., []Address).

More in JSON Tools

All 18 json tools