JSON Formatter
Pretty-print, validate and minify JSON with friendly error messages.
Convert any JSON into Go struct definitions with json tags and pointers for optionals.
Your result is ready — download it below:
Re-encoded without size gain Download links expire within 30 minutes.
No result to display for the current input.
Convert any JSON into Go struct definitions with json tags and pointers for optionals.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Yes — enter a root type name (default Root) and a package name (default main). Non-identifiers and Go keywords are sanitised automatically.
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.
json tags preserving the original keys*T with ,omitempty; purely-null fields stay bare anytype Root []ItemPretty-print, validate and minify JSON with friendly error messages.
Turn any JSON into ready-to-compile Rust struct definitions with serde derives.
Turn any JSON into a TypeScript Zod schema with nullable and optional handling.
Decode JWT header and payload instantly, 100% in your browser — the token never leaves your device.