Skip to content
Tesserae

Keyboard shortcuts

Focus search
/
This help dialog
?
Run the current tool
Ctrl/⌘ +Enter
Copy the output (when an output is focused)
Ctrl/⌘ +C

Shortcuts are ignored while you are typing in an input, a textarea or a select.

Data Formats

JSON to Go Struct

Paste any JSON object or array and get Go struct definitions with json tags that round-trip through encoding/json. Types are inferred: string, bool, int, float64, nested structs, slices, and interface{} with a comment when a value is null or mixed. Field names are Pascal-cased with common acronyms (ID, URL, API) kept uppercase.

On-device No network Offline-ready

🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.

Try:

Options

Your result will appear here

Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.

How it works

From a JSON sample to compilable Go

Paste any JSON value and the tool emits Go type definitions with a struct per shape. Strings become string, booleans bool, whole numbers int and fractional numbers float64; objects become named nested structs and arrays become slices of their element type. The output compiles as-is.

Getting the tags right

Every field carries a json tag matching the original key so the struct round-trips through encoding/json, and omitempty is added by default. Switch tags to none for a plain struct without annotations, for instance when you will tag it by hand.

Names Go will accept

Keys are Pascal-cased, so user_name becomes UserName, and common acronyms stay uppercase — id becomes ID, url becomes URL, api becomes API. Keys that collide after casing, or that are a Go keyword such as func, get a numeric suffix so the file compiles. The root name comes from rootName and defaults to MyStruct.

Nulls, empty containers and mixed arrays

A null value carries no type information and an empty array has no element type, so both become interface{} with a comment explaining why — tighten them by hand. An array of mixed types does the same. Duplicate keys resolve to the last value, matching encoding/json.

Generated locally

The generator is plain string building in this tab — no Go toolchain and no server. A schema from an internal API is never uploaded, and the tool works offline once loaded.

Questions

How are types inferred?

Strings become string, booleans bool, whole numbers int, fractional numbers float64. Objects become nested named structs, and arrays become slices of their element type. A null value or an array containing mixed types becomes interface{}, flagged with a // comment so you can tighten it by hand.

Will the generated struct round-trip my JSON?

Yes: every field carries a json tag matching the original key (with omitempty unless you disable it), so encoding/json marshals and unmarshals the same payloads. Field names are only Go-side cosmetics and never affect the wire format.

How are field and struct names derived?

Keys are Pascal-cased (user_name becomes UserName) and common acronyms stay uppercase (id becomes ID, url becomes URL, api becomes API). Invalid or colliding names get a numeric suffix so the output always compiles.

What about empty containers and null?

An empty array has no element type to infer, so it becomes []interface{}. A null value has no type at all, so it becomes interface{}. Both receive a comment telling you the value was empty or null.

Does it handle nested or repeated shapes?

Nested objects are hoisted into named types (one per shape) so the definition stays readable and reusable. A slice of objects gets its own element type. Duplicate keys in the JSON resolve to the last value, matching Go's encoding/json behaviour.

See category