Lintify Logo
Lintify
Code Generators

JSON to Go Structs

Generate Go structs from JSON with proper json tags, embedded structs, and omitempty support. Ready to paste into any Go project.

JSON input
1
Go
Output will appear here…

Generate Go structs from JSON

Go structs need JSON tags to control how theencoding/json package maps JSON keys to Go fields. Writing those tags by hand is tedious and error-prone — every field needs a tag, the tag needs the original JSON key, and you have to remember whether to add omitempty. Lintify generates the struct and the tags from a sample JSON document, ready to paste into your Go project.

Go field names must be exported (start with an uppercase letter) to be visible to the json package. Lintify converts each JSON key to PascalCase and adds ajson tag that preserves the original key. For example, the JSON key userId becomes the Go field UserId with the tagjson:"userId".

When to use omitempty

omitempty causes the encoder to skip a field if it has its zero value. This is useful for PATCH endpoints where you only want to send fields the client explicitly set. For full responses, leaveomitemptyoff so that zero values are serialized explicitly — the consumer can then distinguish between "field is zero" and "field is missing".

Pointers for nullable fields

By default, Lintify uses value types and lets the zero value represent missing data. If you need to distinguish between a missing field and a field that is present with the zero value, enable the pointer option — every field becomes *T. Pointers add nil-checks at every use site, so only enable them when you really need the distinction. Most APIs do not need this.

Numbers, integers, and json.Number

Integers become int (or int64for large values), decimals become float64, and very large integers (over int64.MaxValue) become json.Number so that no precision is lost. json.Number is a string type that lets you decide later whether to parse as int64 orfloat64 — useful when you do not know in advance how big the numbers will be.

Frequently asked questions

Common questions about the JSON → Go tool.

How are JSON keys mapped to Go field names?
Go field names must be exported (start with an uppercase letter) to be visible to the json package. Lintify converts each key to PascalCase and adds a json tag that preserves the original key. For example, the JSON key userId becomes the Go field UserId with the tag `json:"userId"`.
When is omitempty added?
omitempty is added to every field when you enable the option, which causes the encoder to skip the field if it has its zero value. This is useful for PATCH endpoints where you only want to send fields that the client explicitly set. For full responses, leave omitempty off so that zero values are serialized explicitly.
How are nested objects handled?
Each nested JSON object becomes an inline struct field by default. You can configure the generator to emit a named top-level struct instead, which is useful when the same shape is reused across multiple endpoints. Inline structs keep everything in one place; named structs make reuse easier.
What types are used for numbers?
Integers become int (or int64 for large values), decimals become float64, and very large integers (over int64.MaxValue) become json.Number so that no precision is lost. json.Number is a string type that lets you decide later whether to parse as int64 or float64.
Are pointers used for nullable fields?
By default, no — Lintify uses value types and lets the zero value represent missing data. If you need to distinguish between a missing field and a field that is present with the zero value, enable the pointer option and every field becomes *T. Pointers add nil-checks at every use site, so only enable them when you really need the distinction.

Related tools