Your files stay with you.
JSON→TS

JSON to TypeScript

Paste a JSON response to get matching TypeScript interfaces. Nested objects get their own types and fields missing from some items are marked optional.

Your files stay with you. Nothing uploaded. Nothing saved.

Loading the converter…

How to use the JSON to TypeScript tool

  1. Paste a JSON sample, such as an API response.
  2. Set the root name and choose interface or type.
  3. Copy the generated TypeScript into your code.

How the types are worked out

  • Numbers, strings and booleans map directly to number, string and boolean.
  • Nested objects get their own interface, named after the key.
  • Arrays of objects are merged into one interface, and fields missing from some items are marked optional with ?.
  • Mixed arrays become union types such as (string | number)[].
  • null stays null, because the sample doesn’t show the real type. Replace it with something like string | null.

The more complete your sample, the more accurate the types. If the JSON won’t parse, find the error with the JSON Formatter & Validator.

Frequently asked questions

How are optional fields detected?

In an array of objects, a field that appears in some items but not others is marked optional with a question mark.

Why is a field typed as null?

The sample only had null for that field, so its real type can’t be known. Paste a sample where it has a value, or edit the type by hand.

Are my files uploaded to a server?

No. HushConverts converts everything with code that runs in your browser, so your text and files stay on your device. You can even use most tools offline once the page has loaded.

More encoding & developer