JSON & Data

JSON to TypeScript Interface Generator

Generate TypeScript interfaces from JSON data automatically. Paste an API response or JSON object and get properly typed TypeScript interfaces. Supports nested objects, arrays, optional properties, and more.

JSON Input374 chars
TypeScript Interfaces

What is TypeScript interfaces?

TypeScript interfaces define the shape of objects — what properties exist and their types. Generating interfaces from JSON creates type definitions that enable IDE autocomplete and compile-time type checking.

Why Use This Tool

  • API integration — Generate types from API responses.
  • Type safety — Add types to untyped JSON data.
  • Code generation — Bootstrap TypeScript from sample data.
  • Documentation — Create interface docs from examples.

Tips

  • Use representative JSON with all possible fields.
  • Null values become "null" type — check if they should be optional.
  • Arrays with different types become union types.
  • Review generated types for accuracy.

How to Use the JSON to TypeScript

1

Paste JSON

Enter JSON data from an API or file.

2

Set root name

Name the root interface.

3

Generate

Get TypeScript interfaces.

4

Copy

Copy interfaces to your code.

Worked Examples

Simple object

Input
{"name": "Alice", "age": 30}
→
Output
interface Root {
  name: string;
  age: number;
}

Nested object

Input
{"user": {"id": 1, "email": "a@b.com"}}
→
Output
interface User {
  id: number;
  email: string;
}

interface Root {
  user: User;
}

Frequently Asked Questions

How are arrays typed?

Arrays are typed based on their elements. Homogeneous arrays become Type[], mixed arrays become union types.

What about null values?

Null values are typed as null. Properties that can be null are typed as Type | null.

Can I customize interface names?

Set the root interface name. Nested object interfaces are named based on the property name.