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
- Paste a representative JSON sample.
- Read the generated interface.
- Rename the root interface and adjust any types the sample could not disambiguate, such as nullable fields.
- 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.