1export interface Root {2user: User;3}45export interface Address {6city: string;7zip: string;8}910export interface Profile {11age: number;12address: Address;13}1415export interface User {16id: number;17name: string;18email: string;19isActive: boolean;20roles: string[];21profile: Profile;22lastLogin: string;23}24
JSON to TypeScript converts API responses, fixture files, and pasted JSON into TypeScript interfaces or type aliases that drop directly into your codebase. Nested types extract into named interfaces, optional fields, readonly modifiers, and string literal unions are all configurable so the output matches your team conventions.
Hand-typing every API response shape is tedious. A typo between the type and the runtime payload breaks autocomplete and lets bad data slip into production. This tool reads the JSON, infers the exact shape, and emits clean TypeScript that compiles on the first try.
.json file.UserResponse)..ts file ready to import.Input JSON card hosts three input tabs: Paste content for direct text, Extract from URL for public JSON endpoints (server-proxied to bypass CORS), and Upload JSON for local .json/.txt files up to 5 MB.
Output TypeScript renders the result in a compact line-numbered viewer (Raw Output) and an inlined view (Inline Preview), with Copy and Download .ts actions.
TypeScript Options control root name, output style, optional-field strategy, array notation, nested-type extraction, modifiers, export keyword, semicolons, fallback type, and enum literal detection.
Advanced exposes indent size for the generated code.
T | null.T[] for clean code; Generic Array<T> when team conventions or complex unions need it.Pasted JSON and uploaded files are converted entirely in your browser. The Extract from URL tab is the only path that touches the server, and only to proxy the URL you supply so CORS does not block direct fetches. Nothing is stored.
interface is right for shapes you may want to extend or merge later. type is right for unions, mapped types, or when you need exact assignability. Both produce equivalent runtime behavior and identical IntelliSense in modern TS.
On: every nested object becomes its own named interface (User, UserProfile, UserProfileAddress…) and the parent references it by name. Off: nested objects are inlined into their parent — fewer top-level names but harder to share types across the codebase.
Optional fields = Optional all wraps every property in `?`. Smart marks fields whose value is null in the sample as `T | null`. The default Required keeps the JSON shape exact.
When a string field has a small fixed set of values across the sample (and Use enums for arrays is on), the inferred type becomes a string literal union like `'admin' | 'editor' | 'viewer'` instead of plain string.
`unknown` keeps strict type-checking at the use site so consumers must narrow before access. `any` opts out of type-checking entirely. Recommended: keep Prefer unknown on for safer downstream code.