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

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

Paste your JSON into the input box with "TypeScript" selected and click Convert. The tool produces an export interface for the root object plus one for every nested object, with arrays and primitives typed automatically.
Yes. Switch to "Go" and each field is emitted as a PascalCase Go field with a `json:"key"` tag matching the original JSON key, so encoding/json marshals and unmarshals correctly.
No. All parsing and code generation happens locally in your browser. Your JSON never leaves your device, so it's safe to paste real API responses and private data.
Each nested object becomes its own named type, referenced from the parent. Arrays are typed from their first element; an array of objects yields a reusable item type (e.g. items: Item[] / Items []Item).
The generator types fields exactly as they appear in your sample, so a null value becomes null (TS) or interface{} (Go). To capture optional fields, include them in your sample JSON with a representative value.