Free JSON to TypeScript Converter
Generate TypeScript interfaces or type aliases from any JSON object or array. Paste your JSON and get ready-to-use TypeScript types instantly.
export interface User {
id: number;
name: string;
email: string;
isActive: boolean;
score: number;
tags: string[];
address?: null;
}
export interface Root {
user: User;
createdAt: string;
version: number;
}Common uses
- Generate TypeScript Types from API ResponsesPaste an API JSON response and instantly generate TypeScript interfaces to type-safe your frontend code.
- TypeScript Types for Config and Settings ObjectsGenerate TypeScript interfaces from JSON configuration files to add type safety to your application settings.
- Generate TypeScript Types from Database RecordsConvert JSON-exported database records or ORM query results into TypeScript interfaces for data layer typing.
- Type Mock Data and Test FixturesGenerate TypeScript interfaces from JSON mock data and test fixtures to type your unit tests and Storybook stories.
- Type Third-Party API ResponsesGenerate TypeScript interfaces from third-party API responses where official types are missing or outdated.
How It Works
This tool uses a hand-written recursive type inference algorithm with zero external libraries β JSON.parse to validate and parse the input, then a custom traversal that walks every value in the JSON tree and emits TypeScript interface or type declarations directly in the browser. Nothing is sent to a server.
- 1JSON parsed and validatedYour input is passed to JSON.parse. If it fails, the exact parse error is surfaced immediately below the input. A successful parse produces a typed value tree that drives the rest of the conversion.
- 2Recursive type inferenceA recursive getType function walks every node: primitives map to string, number, boolean, or null; objects trigger a new named interface; arrays of objects have their keys merged across all elements so keys present in only some items become optional and conflicting value types are joined with |.
- 3Collision-safe interface namingEach nested object gets a PascalCase name derived from its JSON key (snake_case, kebab-case, and spaces are all normalised). If two structurally different objects would share the same name, a numeric suffix is appended (Data, Data2, β¦) rather than silently overwriting the earlier definition.
- 4Output rendered and downloadableNested interfaces are emitted first, then the root type, formatted as export interface or export type depending on your selection. The result can be copied to the clipboard or downloaded as a .ts file β all built with a standard Blob and no server round-trip.
Related Tools
JSON Schema to Form
Paste a JSON Schema and get a live, working form β text, number, checkbox, dropdown, and list fields β then copy the JSON your inputs produce. Great for prototyping API request bodies. Runs in your browser.
Typing Speed Test (WPM)
Measure your typing speed (WPM) and accuracy with timed, word-count, quote, custom, and zen tests. Live WPM, raw speed, consistency, a results graph, multiple languages, and per-character feedback β all in your browser.
CSS clamp() Generator
Generate a fluid CSS clamp() value for responsive typography and spacing. Set min/max size and viewport range, see a live preview, and copy the one-line CSS.