JSON to TypeScript & Go Struct Converter
Paste a JSON sample and instantly generate clean, ready-to-use TypeScript interfaces or Go structs — with nested types, arrays, and json struct tags inferred automatically. Everything runs in your browser; your JSON never leaves your device.
Turn JSON Into Type-Safe Code
When you consume an API or load a config file, the data arrives as untyped JSON. Hand-writing the matching TypeScript interfaces or Go structs is tedious and error-prone. This tool infers a complete type definition from a single representative JSON sample, so you can paste the response from your API and drop the generated types straight into your codebase.
How the Type Inference Works
- Objects become named interfaces (TypeScript) or structs (Go), with a separate named type for each nested object.
- Arrays are typed from their elements —
string[]in TypeScript,[]stringin Go. Arrays of objects produce a reusable item type. - Numbers map to
number(TS) orint/float64(Go, based on whether the value is whole). - Go struct tags — every field gets a
`json:"originalKey"`tag so marshalling round-trips the exact JSON keys, even when the Go field name is PascalCased. - Mixed arrays produce a union type (e.g.
(number | string)[]) so nothing is lost.
Tips for Best Results
Give the tool a complete example — include every optional field at least once so it appears in the generated type. For arrays, the first element is used to infer the item shape, so make sure it's representative. You can rename the top-level type with the "Root type name" box; nested types are named automatically from their keys.
Privacy
The conversion happens entirely in your browser with JavaScript. Your JSON — which often contains real API data — is never uploaded or stored anywhere.
Frequently Asked Questions
export interface for the root object plus one for every nested object, with arrays and primitives typed automatically.`json:"key"` tag matching the original JSON key, so encoding/json marshals and unmarshals correctly.items: Item[] / Items []Item).null value becomes null (TS) or interface{} (Go). To capture optional fields, include them in your sample JSON with a representative value.