JSON → TypeScript Generator

Paste any JSON object and instantly get TypeScript interfaces with correct types — 100% browser-based, no data sent to any server.

JSON Input
TypeScript Output
Interfaces: 0 Fields: 0

How to Use

  1. Paste your JSON object or array into the left panel.
  2. Set the root interface name (defaults to Root) and adjust the options below.
  3. Click Generate TypeScript to produce TypeScript interfaces from your JSON structure.
  4. Click Copy on the right panel to copy the generated code to your clipboard.
  5. Paste the interfaces directly into your TypeScript project — nested types are generated automatically.

About This Tool

When working with REST APIs, you typically receive JSON responses that need to be typed in TypeScript. Writing interfaces by hand is slow and error-prone, especially for deeply nested structures with arrays of objects. This tool analyzes your JSON and automatically generates TypeScript interfaces for every object in the hierarchy — including nested objects, arrays, primitive types (string, number, boolean), and null values. Arrays of objects produce a dedicated item interface that is referenced by the parent. You can choose between interface and type aliases, add an export keyword, or mark all fields as optional with ?. All processing runs entirely in your browser; no JSON data is ever sent to a server.

Frequently Asked Questions

What TypeScript types are generated?

The generator detects string, number, boolean, null, typed arrays (T[]), and nested objects — each nested object gets its own named interface. Arrays whose elements are objects use a merged schema from all items and produce an Item interface. Arrays with mixed primitive types produce union types like (string | number)[]. Empty arrays fall back to unknown[].

What happens when the root JSON is an array?

If the root value is a JSON array, the tool uses all elements to infer the item shape and generates a RootItem interface (where “Root” is your chosen name). The root type becomes a type alias: type Root = RootItem[]. This is the standard TypeScript pattern for typed API list responses.

What is the difference between interface and type in TypeScript?

Both interface and type can describe object shapes and are interchangeable for most API-typing use cases. interface supports declaration merging — useful for augmenting third-party types. type aliases are more flexible: they can represent unions, intersections, and primitive aliases. For API response types, use whichever matches your project’s code style; the generated output is valid TypeScript either way.

Related Tools