DevConvertor

JSON to TypeScript

Turn a JSON payload into TypeScript types — nested objects become their own named interfaces, arrays become element unions, and null values are kept as part of the type rather than quietly dropped. Structurally identical objects are emitted once and reused, so a repetitive API response doesn't produce a wall of duplicate interfaces.

ReadyJSON ToolsFree · No account required

Features

  • Interfaces or type aliases, with optional export and readonly modifiers
  • Custom root type name
  • Nested objects, arrays, unions, and nullable values
  • Identical shapes de-duplicated into a single interface
  • Copy, or download as a .ts file

How to use

  1. Paste a JSON sample — an API response works well.
  2. Set the root type name and pick interface or type alias.
  3. Copy the generated TypeScript, or download it.

Example

This JSON:

{
  "name": "Shivam",
  "age": 24
}

produces:

export interface Root {
  name: string;
  age: number;
}

FAQ

How are nested objects handled?
Each nested object becomes its own named interface, named after the property it came from. Objects with identical shapes are emitted once and reused, so a list of 50 identical records produces one interface, not fifty.
What happens to null values?
They become part of the type — a property that is null in the sample is typed `null`, and a mixed array produces a union. Nothing is silently widened to `any`, because a type that hides a null is worse than one that admits it.
What about empty arrays?
An empty array has no elements to infer from, so it's typed `unknown[]`. Add a representative element to the sample to get a real element type.
Are the generated types exact?
They describe the sample you pasted, which is not the same as the API's full contract. A field that's optional in the API but present in your sample will look required — review the output before shipping it.