Skip to content
ToolsOnDuty - free online tools
Converters

JSON to Go Struct Converter

Generate Go structs from a JSON sample.

Free foreverRuns in your browserNo sign-up
Go structs

About the JSON to Go Struct Converter

Generate Go structs with json tags from a sample JSON object or array, including nested objects.

Paste an API response and get ready-to-use structs for unmarshalling in Go.

Saves you from hand-writing field names, types and json tags.

Key features

  • Structs for nested objects
  • Adds json tags for each field
  • Infers string, int, float64, bool and slices
  • Copy the result instantly

How to use

  1. 1Paste a representative JSON sample.
  2. 2Read the generated Go structs.
  3. 3Copy them into your project.

Examples

Object to struct
Input: {"id":1,"name":"Ada"}
Output: type Root struct { Id int `json:"id"` Name string `json:"name"` }

Each key becomes an exported field with a json tag.

Decimal field
Input: {"price":9.99}
Output: type Root struct { Price float64 `json:"price"` }

A number with a decimal point is typed as float64.

Frequently asked questions

How are numbers typed?
Whole numbers become int and numbers with a decimal point become float64, based on the sample value.
Are json tags included?
Yes. Each field gets a json tag matching the original key name.
Is my data uploaded?
No. The generation runs entirely in your browser.