DuckyTools
Home Developer JSON to TypeScript

JSON to TypeScript Developer

Turn a JSON sample into TypeScript interfaces you can paste straight in.

JSON to TypeScript is a free online tool that turn a JSON sample into TypeScript interfaces you can paste straight in. It runs entirely in your web browser using plain JavaScript, so files are processed on your own device and never uploaded to a server. There is no sign-up, no file size limit imposed by the site, no watermark and no paid tier.

Price
Free — no account, no quota, no watermark
Category
Developer
Where it runs
In your browser, on your device
Files uploaded
None
Technology
plain JavaScript
Settings
1
Works offline
Yes, after the first visit

About JSON to TypeScript

Interfaces are generated from a JSON sample by inferring each field's type. The limitation is inherent and worth stating plainly: a sample shows what was present once, not what is possible. A field that happened to be non-null in your sample is typed as non-nullable, and an empty array yields `unknown[]`. Treat the output as a strong first draft, then mark the optional fields yourself.

How to use it

  1. Paste the text you want to run through json to typescript.
  2. Set root name.

The one setting

SettingWhat it doesDefault
Root nameFree text.Root

Under the hood

Runs onplain JavaScript — runs the whole thing
ControlsRoot name

Questions

Why is my optional field not marked optional?

Because it was present in the sample. Absence cannot be inferred from a single example — feed it several representative payloads, or add the `?` by hand where the API documentation says a field may be missing.

How are nested objects handled?

Each becomes its own named interface, referenced from the parent, rather than being inlined. That keeps the result readable and the pieces reusable.