JSON to Go struct

Generate idiomatic Go structs (with json tags) from a JSON sample.

Runs in your browser Instant No signup, no tracking

About this tool

Paste a JSON sample and receive Go struct definitions ready to drop into your project. Field names are PascalCased for export; the original key is preserved via a `json:"..."` tag so `encoding/json` round-trips cleanly. Nested objects become their own named structs. Integers map to `int64`, floating-point values to `float64`, and unknown or empty values to `interface{}` so `go vet` stays quiet.

Example

Paste the input on the left and you will get output like this:

Sample JSON

{
  "user": {
    "id": 42,
    "name": "Ada Lovelace",
    "is_admin": true,
    "created_at": "2024-01-01T00:00:00Z"
  }
}

Resulting Go

type User struct {
  Id        int64  `json:"id"`
  Name      string `json:"name"`
  IsAdmin   bool   `json:"is_admin"`
  CreatedAt string `json:"created_at"`
}

type Root struct {
  User User `json:"user"`
}

How to use JSON to Go struct

  1. Paste or type your JSON into the left pane.
  2. The Go appears instantly in the right pane. Conversion runs in your browser — nothing is uploaded.
  3. Copy the result to your clipboard or download it as a file.

FAQ

Why int64 instead of int?
Because JSON numbers may exceed 32-bit range on 32-bit builds. int64 is portable; change to int if you're sure your values fit.
Can I customize tags (e.g. omitempty)?
Not from the UI. Add `,omitempty` after each field manually — a one-line find-and-replace in your editor.
How are polymorphic arrays handled?
Only the first element is inspected. For heterogeneous slices, use `[]interface{}` or a tagged union and unmarshal by hand.