Online JSON to TypeScript Interface Generator

Convert raw JSON data into clean, strongly typed TypeScript interfaces or type aliases with nested type extraction.

100% Client-Side Processing — your JSON never leaves this browser. Works offline. How it works

0 lines • 0 bytes Ready
Tip: drop a file anywhere on the editor
Input
Paste, type or drop a file
1
Result
Updates as you type
// Output will appear here…
About this tool

How the JSON to TypeScript works

Generate type-safe TypeScript interfaces and types from JSON payloads. Nested interfaces, union detection, and optional fields handled automatically.

Nested Interface Extraction

Automatically creates clean, distinct PascalCase interfaces for nested objects (e.g. Address, Item).

Optional & Union Field Detection

Scans arrays of heterogeneous objects to identify optional properties (field?: type) and union types.

Interface or Type Alias Toggle

Generate export interface or export type declarations based on your codebase conventions.

Download .d.ts or .ts

Copy declarations directly into your frontend or backend project, or download as a definition file.

FAQ

Common questions

How does this tool detect optional fields?

When you provide an array of objects, the generator inspects all objects. If a property appears in some items but not all, it is marked with ? (optional).

Does it handle mixed array types?

Yes! Arrays with mixed elements (e.g. strings and numbers) generate union types such as (string | number)[].

Can I choose between interface and type?

Yes! Use the toggle in the toolbar to switch between "interface" and "type" output.

Can I change the root interface name?

Yes, customize the root interface name (e.g. UserResponse, ApiResponse) in the options input.