LazyTools

🔒 Every tool runs in your browser — the files and values you enter are never uploaded to any server. How it works

🐹 JSON to Go Struct Converter

Paste JSON and get Go structs with the right field types and json:"…" tags — nested objects and slices handled for you.

2 structs generated

Rate this tool:
Anonymous — no account, no identifier

How the json to go struct converter works

The converter parses your JSON and emits idiomatic Go struct definitions. Field names are PascalCased (so user_name becomes UserName) while the original key is preserved in a json:"user_name" tag. Types are inferred: whole numbers become int, other numbers float64, booleans bool, strings string, null and empty arrays interface{}, arrays become slices of the element type, and nested objects become their own named structs referenced from the parent.

This gives you the boilerplate for unmarshalling JSON into typed Go structs in seconds. A couple of things to check by hand: a JSON number with no decimals is typed as int, but if the field can exceed 32-bit or you need decimals you may want int64 or float64; and fields that are sometimes null may need pointer types (*string) or omitempty tags. It’s a fast scaffold you refine, not a substitute for knowing your API. Everything runs locally in your browser.

Frequently asked questions

How do I convert JSON to a Go struct?

Paste a JSON sample and the tool generates Go struct definitions with json tags. Set the root struct name if you like, then copy the output straight into your Go file.

Does it keep the original JSON field names?

Yes — the Go field is PascalCased (as Go requires for exported fields) and the original key is preserved in a json:"original_key" tag, so json.Unmarshal maps correctly.

How are numbers typed?

Whole numbers become int and numbers with a decimal point become float64. If your values can be large or must always be floating-point, adjust to int64 or float64 after generating — inference can only go on the sample.

What about null or optional fields?

null and empty arrays are typed as interface{}. For fields that may be absent or null in real data, consider pointer types (e.g. *string) or the omitempty tag, which the tool leaves for you to add deliberately.

Is my JSON uploaded?

No — the conversion runs entirely in your browser and works offline, so your data never leaves your device.

Related developer tools

From the blog