Developer Tools

JSON to TypeScript Interface Generator

Turn a JSON sample into exported TypeScript interfaces, with nested objects and typed arrays, so your API responses are type-checked.

Free to use Browser-based processing Instant results

Input JSON

Paste your JSON or upload a JSON file.

INPUT

Generated Output

Your converted code will appear here.

OUTPUT

            

Conversion Format

Select the output format you need.

FORMAT

About the JSON to TypeScript Interface Generator

Turn a JSON sample into exported TypeScript interfaces, with nested objects and typed arrays, so your API responses are type-checked.

Typing API responses in TypeScript catches mistakes, such as a misspelled property or a number treated as a string, at compile time instead of in production. This generator reads a JSON sample and produces an exported interface for the root object and for every nested object. You can paste the result straight into a .ts file and use it with fetch, Axios or Angular's HttpClient.

How to use it

  1. Paste a JSON sample into the input editor or upload a .json file.
  2. Select Convert.
  3. Review the output, then copy it or download it.

How JSON types are mapped

JSON valueGenerated as
stringstring
number (42 or 9.99)number
true / falseboolean
nested objecta new exported interface
arrayT[] (T taken from the first element)
nullany

Example

This input:

{
  "id": 1,
  "name": "Ada",
  "price": 9.99,
  "active": true,
  "tags": ["new", "sale"],
  "address": { "city": "London", "zip": "N1" }
}

produces this output:

export interface Root {
  id: number;
  name: string;
  price: number;
  active: boolean;
  tags: string[];
  address: Address;
}

export interface Address {
  city: string;
  zip: string;
}

Limitations and things to review

Things to check in the generated interfaces:

  • Every property is generated as required. If a field is sometimes missing, mark it optional (field?: string).
  • null values become any. Replace them with a union such as string | null to keep type safety.
  • Only the first element of an array is inspected, so arrays of mixed shapes need a union type added by hand.
  • JSON keys that aren't valid identifiers (for example "first-name") must be quoted: 'first-name': string.
  • Nested objects with the same key name produce duplicate interface names. Rename one of them.

Frequently Asked Questions

For describing the shape of JSON objects, both work. Interfaces can be extended and merged, which makes them a common default for API models. You can change export interface Root { ... } to export type Root = { ... } if your codebase prefers type aliases.

No. Interfaces are erased at compile time, so they only describe the shape you expect. If you need runtime validation of untrusted API responses, use a schema library and derive the type from the schema.

No. The conversion runs in your browser with JavaScript, and your JSON isn't sent to or stored on DevToolsWorld servers.

The converter shows the parser's error message instead of output. Use the JSON Formatter to validate and fix the document, then convert it again.

Yes. It's free and doesn't require an account or any installation.