Free · Private · In-Browser

JSON To Go Struct

Infer a Go struct from a representative JSON object.

Output
 

Infer a Go struct from JSON

Writing Go structs to match a JSON payload by hand is tedious and easy to get wrong. This tool infers a struct — fields, types, and JSON tags — from a representative JSON object, giving you a solid starting point to paste into your Go code.

It reads the shape and types of your sample and generates matching struct definitions, saving the repetitive typing and the guesswork around tags. Paste a JSON object, copy the generated struct, and adjust types as needed.

Inferred structs, locally

It infers field names, types, and json tags from a sample payload, saving tedious transcription. Inference runs in your browser and never uploads your data.

Frequently asked questions

How are Go types chosen?

From your sample values: whole numbers become int, decimals float64, true or false bool, text string, and arrays use the type of their first item.

Are JSON tags included?

Yes. Each field gets a json tag with the original key, and field names are converted to Go-style PascalCase.

How are nested objects handled?

They get a placeholder type. Generate a separate struct for each nested object and reference it by name.

Take it further
Developer Tools

Practical utilities for everyday web development work.

Learn more