JSON to Go Struct Converter

Runs in your browser — your data is never uploaded.

Turn a JSON sample into Go structs with the json tags already written. Field names follow Go’s initialism convention — ID, URL, HTTPBody, not Id, Url, HttpBody — so the output passes a linter and a code review rather than needing a rename pass first. Optional fields become pointers with omitempty, which is how Go distinguishes an absent value from a zero one. Runs entirely in your browser.

0 characters · runs entirely in your browser

How to use JSON to Go

  1. 1

    Paste a JSON sample, ideally a full response so optional fields are visible.

  2. 2

    Set a name for the root struct if you want something other than Root.

  3. 3

    Click “Generate” and copy the structs into your package.

Share

Embed this tool on your site

Paste this where you want the tool to appear. It runs entirely in your visitor's browser — no uploads, no account, no tracking.

Please keep the attribution line — it's what keeps these tools free.

Need a different size, a dark theme, or a different tool? Build an embed lets you preview it first.

Frequently asked questions

Why are some fields pointers?+

Because Go has no way to tell an absent int from an int that happens to be 0. A field missing from some records is emitted as *int with omitempty, so you can check for nil instead of guessing whether a zero was real.

Why is it ID and not Id?+

Go’s style guide keeps initialisms fully capitalised, and golint flags Id, Url and Http. The generator applies the standard list — ID, URL, API, HTTP, JSON, UUID and the rest — including inside camelCase, so htmlBody becomes HTMLBody.

Does it distinguish int from float64?+

Yes. A whole number is typed int and a number with a decimal point float64. If a field is a whole number in one record and fractional in another, it widens to float64 — which is what you want, since the narrow type would fail to unmarshal.

What about nested objects?+

Each becomes its own named struct, referenced by field, rather than an anonymous inline struct. Named types are what you actually want when you go on to write methods on them.

Do the json tags keep my original field names?+

Yes. The Go field name is idiomatic Go, and the tag carries the exact key from your JSON — including snake_case, kebab-case or anything else — so unmarshalling works unchanged.