Tarayıcınız güncel değil

Bu siteyi görüntülemek için tarayıcınızın veya cihazınızın işletim sisteminin güncellenmesi gerekiyor.

Your browser is out of date. Please update iOS or your browser to view this site.

Skip to main content
Gizke.com
Blog

JSON to TypeScript

Runs on your device. Nothing is sent.
Declare as

TypeScript

Paste JSON to see its TypeScript types.

Paste JSON and get TypeScript interfaces or types - nested objects named, arrays merged, optional keys and unions inferred. Nothing leaves your browser.

Paste an API response, a config file or any JSON sample and get TypeScript declarations you can drop into your code. Every nested object becomes its own named interface, arrays of objects are merged so keys missing from some items become optional and values of different kinds become unions, and objects with the same shape share one declaration. Choose interface or type, export, readonly and how optional keys are written, then copy the code or download a .ts file.

Frequently asked questions

How are nested types named?
After the key they appear under, in PascalCase: an address object becomes Address, and the items of a users array become User. If two different shapes would get the same name, the second gets a number (Item2).
Why is a field optional or a union?
In arrays every item is compared. A key missing from some items is marked optional, and a key that holds a number in one item and a string in another becomes string | number. Give a representative sample for the best types.
What about dates, enums and empty arrays?
JSON has no date type, so dates stay string, and a set of fixed values stays string too - narrow them by hand. An empty array becomes unknown[] because there's nothing to infer from.
Is my JSON uploaded?
No. Parsing and generation happen in your browser, so private API data and tokens in your sample stay on your device.

Share this tool

BlogAboutContactTerms of UsePrivacy Policy