Turn a JSON response into Go structs
Hand-writing struct fields for a 40-field API payload is how typos ship. Paste the sample, get the structs with tags.
Tools used in this guide
The job
You're wiring a new API client and the docs give you a JSON example, not a spec. The struct fields, JSON tags and nesting can be generated from the example — you only check the types it couldn't infer.
Paste a sample
Paste a real response into the input and generate. You get a named root type plus nested structs, each field tagged `json:"name"` matching the wire keys.
- Arrays are merged across elements — a []item where one element omits a field still gets the field, as a pointer-friendly type.
- null-valued fields can't be typed from the sample; they come out as the interface{}-equivalent. Give them real values if the API sometimes sends them.
Before you commit
Field names are derived by PascalCase + common initialisms (Id→ID, Url→URL). The output compiles, but eyeball integer vs float — a sample that only shows whole numbers can't prove the API never sends fractions. Input limit: 2,000,000 characters, depth 40.