>
B's Code

JSON to TypeScript

Paste JSON, get a matching TypeScript interface. Runs entirely in your browser.

[ INPUT ]
[ NAME ]
[ OUTPUT ]
// waiting for valid JSON

About JSON to TypeScript

Writing types by hand for an API response is tedious. This infers a TypeScript interface from an example payload — objects become interfaces, arrays become typed arrays, and primitives get their obvious type.

How to use it

  1. Paste a representative JSON sample.
  2. Read the generated interface.
  3. Rename the root interface and adjust any types the sample could not disambiguate, such as nullable fields.
  4. Copy it into your project.

Frequently asked questions

Will the types be perfect?
They reflect the sample you paste. A field that is null in the sample, or missing from some items, may need a manual null union or optional marker. Provide a sample that covers the real variation.
Does it handle nested objects and arrays?
Yes. Nested objects become their own interfaces and arrays are typed by their elements.
Is my JSON sent anywhere?
No. Inference runs in your browser.