JSON to TypeScript
JSON to TypeScript
Convert JSON samples into TypeScript interfaces and type aliases. Automatically merges object-array fields, infers optional fields and null unions, and generates suitable type declarations for empty arrays and empty objects. Useful for API response modeling, frontend type bootstrapping, and data structure organization.
Quick Start
Common Scenarios
Turn real API responses into starter TypeScript models for frontend pages, SDK clients, or integration tests.
Inspect mixed object arrays to see optional fields and union types before you formalize an API contract.
Convert mock JSON data into quick type definitions for fixtures, Storybook stories, or prototypes.
Review nested declarations such as User and Meta when backend payload shapes change.
Usage Advice
Limitations & Compatibility
Privacy & Security
FAQ
Object roots generate interface declarations. Array and primitive roots generate type aliases. For a top-level object array, the root stays a type alias such as type Root = RootItem[];, and the item structure is declared separately.
With no sample items or properties, the generator cannot infer anything narrower. It keeps empty arrays as unknown[] and empty objects as interfaces extending Record<string, unknown> until you paste more representative data.
If the name you enter is already a valid TypeScript identifier, it is preserved exactly, for example APIResponse. Invalid names are normalized into a stable PascalCase identifier before generation.
The current generator normalizes nested names from property paths and resolves collisions deterministically. That is why newer output uses names such as User, Meta, or FooBarClass instead of always prefixing them with the root name.
The current output contract intentionally returns plain declarations without export. This keeps the output neutral, and you can add export yourself to match your project style.