New 58+ tools are now available — built to keep your workflow moving.

JSON to Go Struct Generator

Convert any JSON into Go struct definitions with json tags and pointers for optionals.

Paste any JSON and press Run to get Go struct definitions you can paste into a .go file. Fields are exported with json tags, optional and nullable fields become pointers (*T) so encoding/json round-trips them exactly. Only the Go standard library is needed. Nothing is sent to storage.

Choose a file first — Run stays disabled until the file is selected.

File ready — press Run to start.

Optimizing your file…

Your result is ready — download it below:

Re-encoded without size gain Download links expire within 30 minutes.

This image appears to be already optimized — try a lower quality setting for a smaller file.
No logo or watermark was detected in the marked corners — your images were delivered unchanged.

No result to display for the current input.

JSON to Go Struct Generator Online

Convert any JSON into Go struct definitions with json tags and pointers for optionals.

Generate Go Structs from JSON

Paste any JSON document and get Go struct definitions in seconds. The generator infers field types, turns arrays into slices, wraps nulls in pointers (*T), and emits one exported, PascalCase field with a json tag per key. Only the Go standard library is needed, so the output compiles with go build as-is.

How It Works

Paste a JSON document, choose a root type name and package name, then press Run. The generator creates one struct per object, named from the JSON path — address becomes Address, company.address becomes CompanyAddress. Arrays become slices ([]T); when an array holds objects, their fields are merged across every sample so a key missing from some entries automatically becomes a pointer.

Type Inference

Booleans map to bool, integers to int64, floats to float64 and strings to string. Mixed integer/float values are unified to float64. Any value whose type cannot be determined becomes any, which encoding/json handles natively.

JSON Tags & Pointers

Every field is exported as a PascalCase Go identifier and tagged with the original JSON key, so un-marshalling keeps the exact wire format. Fields that are null or missing in some samples become pointers (*T) with ,omitempty, letting encoding/json distinguish "absent" from null — the behaviour you need for polymorphic and partial APIs. When a field is only ever null and no type can be inferred, it stays bare any, which already holds nil.

Non-Object Roots

If your JSON is an array or a scalar, the generator emits a type alias such as type Root []Item or type Root string, with the element type defined alongside it when it is an object.

Privacy & Security

Your JSON is processed only to produce the structs and is never stored, logged or shared. There is no upload, no account and no watermark.

Frequently asked questions

Why do optional fields become pointers?

Because encoding/json cannot tell "key absent" from an empty value for scalars. A pointer (*T) is nil when the key is missing, so marshalling round-trips your JSON exactly.

How are null values handled?

Fields whose value is null in some samples become pointers, which carry the nil value for absent or null data. Ambiguous types default to any.

Do I need any external Go packages?

No. The generated file only imports nothing beyond the standard library and stops before any import block, so it compiles with go build for any Go module.

Can I control the package and type names?

Yes — enter a root type name (default Root) and a package name (default main). Non-identifiers and Go keywords are sanitised automatically.

About this tool

JSON to Go Struct Generator turns any JSON document into Go struct definitions. Objects become their own struct types with exported fields and json tags, arrays become slices ([]T), and optional or nullable fields become pointers (*T) so encoding/json round-trips them exactly.

How to use: paste some JSON, optionally set the root type and package name, then press Run. Only the Go standard library is required.

  • Exported PascalCase fields with json tags preserving the original keys
  • Optional and nullable fields become *T with ,omitempty; purely-null fields stay bare any
  • Array samples merged — keys missing from some entries become pointers
  • Non-object roots become type aliases such as type Root []Item

Related tools