Code Generators · Runs in your browser

JSON to Go Struct Generator

Paste a JSON sample and get ready-to-use Go structs, with nested types, arrays and optional fields worked out for you. Ideal for unmarshalling API responses with encoding/json.

JSON
Drop a file to load it
Go
Waiting for input

How to use it

  1. Paste a representative JSON sample, such as an API response.
  2. Set the root type name and pick a style: structs with json tags.
  3. Copy the Go code or download it as a file.

Tags and names

Each field gets a json:"…" tag, and names follow Go conventions, including initialisms like ID and URL.

Optional fields

Fields that may be missing or null become pointers and get omitempty.

Integers vs. decimals

Number types come from how the number is written in your sample: 3 is an integer, 3.0 and 3.5 are decimals, and long IDs use a 64-bit type.