Skip to content
AllInOneTools

JSON to TypeScript

Generate TypeScript interfaces or types from a JSON sample.

Runs in your browser – your files are not uploaded

How to use JSON to TypeScript

  1. 1

    Paste a JSON sample into the left field.

  2. 2

    Set the root type name and the options you prefer.

  3. 3

    Copy the TypeScript code or download it as types.ts.

About JSON to TypeScript

Typing an API response by hand is tedious. Paste a JSON sample and this tool infers TypeScript definitions for it, including nested objects as separate interfaces and arrays with mixed item types.

Fields that are missing in some array items become optional. You can choose type aliases instead of interfaces, mark null fields as optional instead of adding | null, make all properties readonly and set the name of the root type.

Frequently asked questions

How accurate are the generated types?

They only reflect the sample you paste. A field that is always a string in your sample but sometimes a number in reality will be typed too narrowly, so use a representative sample and review the result.

Are string literal unions or enums generated?

No. Strings are always typed as string and numbers as number; narrowing them to specific values is up to you.

Is my JSON uploaded?

No. The conversion runs entirely in your browser.