JSON to Go Struct

Generate Go structs with JSON tags from a JSON sample.

100% private — everything runs in your browser

How to Use

  1. 1

    Paste a JSON sample — an API response works well.

  2. 2

    Set the package and root struct name.

  3. 3

    Generate, then copy the Go code into your project.

Examples

API response

Input

{"id":1,"user":{"name":"Ada"}}

Output

type Root struct { ID int `json:"id"`; User struct { Name string `json:"name"` } `json:"user"` }

Optional field

Input

[{"id":1},{"id":2,"name":"Alan"}]

Output

Name becomes a pointer or omitempty field because it is missing in one item.

FAQ

How are numbers typed?

Integers become int and decimals become float64, so the generated code compiles as-is.

What about missing keys?

Fields missing in some array items are marked with omitempty so the struct still matches the payload.

Is my JSON uploaded?

No. Structs are generated locally in your browser.

Related Tools