Skip to content
snip tools

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 browser
 

How to convert JSON to Go

  1. Paste your JSON. Paste a JSON object or array.
  2. Name the root struct. Optionally rename the root struct.
  3. 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

How does it generate Go structs?
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 become int while decimals become float64.
How are optional and null values handled?
A key missing from some objects in an array gets ,omitempty on its tag. A value that is sometimes null and sometimes a single type becomes a pointer (*T); always-null or mixed types become interface{}.
Are field names valid Go?
Yes — keys are converted to exported PascalCase identifiers, and the original key is preserved in the JSON tag so marshalling round-trips.
Is my JSON uploaded?
No. Generation runs entirely in your browser.