JSON to Go struct generator
Generate Go structs with json tags from JSON. Nested objects, arrays and optional fields are inferred. Runs in your browser.
Runs 100% in your browserHow to convert JSON to Go
- Paste your JSON. Paste a JSON object or array.
- Name the root struct. Optionally rename the root struct.
- Copy the structs. Copy the generated Go into your project.
About JSON to Go
When you're consuming a JSON API in Go, hand-writing the structs and tags is busywork. Paste a sample
payload and get ready-to-use structs with correct json tags, sensible numeric types and
omitempty where fields are optional. Review pointer and interface choices
for nullable or mixed fields before committing. Prefer TypeScript? Use the
JSON to TypeScript generator.
Frequently asked questions
- It infers a struct for each JSON object, with exported fields and
json:"…"tags matching the original keys. Arrays of objects are merged into one struct, and integer-only numbers becomeintwhile decimals becomefloat64. - A key missing from some objects in an array gets
,omitemptyon its tag. A value that is sometimes null and sometimes a single type becomes a pointer (*T); always-null or mixed types becomeinterface{}. - Yes — keys are converted to exported PascalCase identifiers, and the original key is preserved in the JSON tag so marshalling round-trips.
- No. Generation runs entirely in your browser.