JSON to TypeScript Interfaces

Paste sample JSON and get TypeScript interfaces: nested objects, arrays, optional fields and unions.

Also called: JSON to TS, TypeScript interface generator.

FreeNo sign-upRuns in your browser
DEVELOPER

JSON to TypeScript Interfaces

Paste sample JSON and get TypeScript interfaces: nested objects, arrays, optional fields and unions.

Runs locally in your browser
Ready. Fill in the fields above, then press Run tool.
Privacy note: this tool runs in your browser, so the text you enter stays on your device.

Find a tool

Loading tools…

Watch: how to use the JSON to TypeScript Interfaces (12 seconds)

Recorded on a phone, steps written on screen, no sound.

About the JSON to TypeScript Interfaces

Paste sample JSON and get TypeScript interfaces, including nested objects, arrays, optional fields and union types. Choose the root type name and whether to add “export”.

How to use the JSON to TypeScript Interfaces

  1. Add your inputFill in sample JSON and root type name. An example is already filled in, so you can press Run tool first to see how it works.
  2. Pick the optionsadd "export" (the defaults suit most uses).
  3. Press Run toolThe result appears right under the button.
  4. Copy or download the resultCopy text results with Copy output; when the tool makes a picture or file, use its Download button.

This tool works inside your browser: what you enter stays on your device.

Example

A sample input and the result the JSON to TypeScript Interfaces gives for it (produced by the tool itself, not typed by hand).

Sample JSON
{"id":1,"name":"Sara","tags":["a","b"],"address":{"city":"Lahore","zip":null}}
Root type name
Root

Result:

interface Root {
  id: number;
  name: string;
  tags: string[];
  address: Address;
}

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

Good to know

What you need
You type or choose: Sample JSON, Root type name
Where it runs
In your browser, on your device.
Cost
Free, no sign-up.

Questions

How are optional fields found?

A key missing from some array items becomes optional.

Are dates typed as Date?

No, JSON dates are strings.

More tools in Developer

See all Developer tools