Skip to main content

JSON to Go Struct

Generate Go struct definitions from JSON data.

convertgogolang
Read the guide
Shortcuts:⌘ KSearch

Frequently Asked Questions

Why did some fields become interface{} or []interface{}?

Null values map to interface{}, empty arrays map to []interface{}, and mixed-type arrays also fall back to []interface{}.

Can it add json tags and omitempty?

Yes. JSON tags are enabled by default, and omitempty is a separate toggle that appends ,omitempty inside each tag.

What numeric types does it generate?

Whole numbers become int64 and decimals become float64. There is no narrower int or float inference.

What happens if my top-level JSON is an array or a primitive?

A root array becomes a type alias like type Root []ItemType. A root primitive becomes a type alias to its inferred Go type.

Why were my field names changed?

Field names are normalized to exported PascalCase identifiers, and names starting with digits get a Field prefix. The original JSON key is preserved in the tag when tags are enabled.

Related Tools