Skip to content
ToolMug

JSON to Go Struct Converter

Paste JSON and get Go struct definitions with json tags, ready for encoding/json. Field names follow Go conventions, nested objects become their own types, and columns are aligned like gofmt.

Runs in your browser — nothing you enter is uploaded

How to use

  1. Paste a JSON sample, or click Load sample.
  2. Set the name of the root struct.
  3. Copy or download the generated code and add it to your package.

Options explained

Root type name
Name of the top-level struct. Nested structs are named after their keys.

Examples

{"user_id": 7, "email": null, "tags": ["a"]} becomes:

type Root struct {
	UserID int64    `json:"user_id"`
	Email  any      `json:"email"`
	Tags   []string `json:"tags"`
}

Frequently asked questions

How are field names chosen?

Keys are converted to exported PascalCase names, and common initialisms are written in capitals as Go style recommends — user_id becomes UserID and homeUrl becomes HomeURL. The original key is kept in the json tag.

When does it use pointers and omitempty?

Keys missing from some array items get omitempty. Values that are sometimes null become pointers (*string) so null can be told apart from an empty value; optional nested structs are pointers as well.

Which number types are used?

Whole numbers become int64 and numbers with decimals become float64. If a key has both in different items, float64 is used.

Is my JSON uploaded?

No. The types are generated in your browser, so API responses with real data stay on your device.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools