JSON to TypeScript & Go Struct Converter

Generate TypeScript interfaces or Go structs from a JSON sample. Inference reflects that sample, not every valid record; review nullability, optional fields, numeric precision, names, and the generated declarations before use.

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. TypeScript examines all array elements and combines their types. Go uses the first element, so provide a representative homogeneous array and review mixed arrays manually. You can rename the top-level type with the "Root type name" box; nested types are named automatically from their keys.

Privacy

Input processing is local to this tool. Shared page features may make network requests, and enabled browser drafts may retain text locally. Avoid pasting credentials or confidential material.

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.
Input processing is local to this tool. Shared page features may make network requests, and enabled browser drafts may retain text locally. Avoid pasting credentials or confidential material.
Each nested object becomes its own named type, referenced from the parent. TypeScript infers from all array elements, using unions when needed; Go infers from the first element only. 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.