Skip to main content

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.

Works offline once loaded
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.

  1. 1
    JSON parsed and validated
    Your 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.
  2. 2
    Recursive type inference
    A 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 |.
  3. 3
    Collision-safe interface naming
    Each 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.
  4. 4
    Output rendered and downloadable
    Nested 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

Frequently Asked Questions