Stax

JSON to TypeScript Generator

Convert JSON objects to TypeScript interfaces instantly.

interface Root {
  id: number;
  name: string;
  email: string;
  isActive: boolean;
  score: number;
  address: Address;
  tags: string[];
  createdAt: string;
}

interface Address {
  street: string;
  city: string;
  pincode: string;
}

ℹ️ Arrays are typed from the first element. Nested objects become separate interfaces. Optional fields (null values) are typed as null — mark them field?: Type manually if needed.

Why use a JSON to TypeScript converter?

Manually writing TypeScript interfaces for complex API responses is tedious and error-prone. This tool auto-generates accurate interfaces from any valid JSON in seconds — saving time and eliminating typos in property names or types.

Features

  • Recursive interface generation for deeply nested objects
  • Correct array typing including union types for mixed arrays
  • Custom root interface name
  • One-click copy to clipboard
  • 100% client-side — no data leaves your browser

Frequently asked questions

How does JSON to TypeScript conversion work?
The tool recursively walks your JSON structure. Objects become interfaces, arrays infer their item type, and primitives map to string, number, boolean, or null. Nested objects generate separate named interfaces.
Does it handle nested objects and arrays?
Yes. Nested objects generate their own interface (e.g., AddressInterface), and arrays are typed as ItemType[]. The tool handles multiple levels of nesting automatically.
What happens with mixed-type arrays?
If an array contains elements of different types, the tool generates a union type (e.g., string | number). Empty arrays are typed as unknown[].
Can I customise the root interface name?
Yes — there is a 'Root interface name' input at the top. Change it to anything you like (e.g., ApiResponse, UserData) and the output updates instantly.
Is my JSON data sent to a server?
No. All conversion happens entirely in your browser using JavaScript. Your JSON never leaves your device.

Related tools