Skip to content
migration.tools
JSON to Go struct

JSON to Go struct converter

Rewriting a service in Go, or calling a JSON API from one? Paste a response and get idiomatic structs: exported field names, json tags, and named types for nested objects.

Options

JSON

Go struct

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your JSON or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the Go struct or download it. Drop several files to convert a batch into one ZIP.

Naming and type choices

Field names are converted to exported CamelCase with Go's initialisms respected — id becomes ID, avatar_url becomes AvatarURL. Each field keeps its original key in a json tag.

Integers are int64 and decimals float64. ISO datetimes become time.Time, with the import added. Fields that can be null become pointers, and fields missing from some array elements get omitempty.

Questions

Why int64 instead of int?

JSON has no integer size, and IDs from other systems often exceed 32 bits. int64 is the safe default; narrow it where you know the range.