← All text tools

JSON to TypeScript

Generate TypeScript interfaces from sample JSON, with optional fields and nested types.

  • Free
  • No sign-up
  • Works on any device

About JSON to TypeScript

Paste sample JSON and get TypeScript interfaces, with nested objects as separate types and arrays typed by their elements. Fields missing in some array items can be marked optional with a question mark. It gives a quick start for typing API responses, which you can then refine by hand.

How to use JSON to TypeScript

  1. Paste a sample JSON response.
  2. Set the root type name and options for optional fields.
  3. Copy the TypeScript interfaces into your code.

Why use this tool?

Also known as

Frequently asked questions

Should I use interface or type for API data?

Either works for plain objects. Interfaces are common for object shapes and can be extended, while type aliases suit unions. This tool outputs interfaces.

Why are all my fields required?

The tool sees only the sample you give it. If a field may be missing, add a second sample without it or mark it optional by hand with a question mark.

How are arrays of mixed items typed?

Mixed arrays usually become a union type of the item shapes. Review the result and tighten it if your data is more specific.

Is JSON to TypeScript free?

Yes. JSON to TypeScript on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.

Can I put JSON to TypeScript on my own website?

Yes. Use the Embed on your site button under the tool to copy a short piece of code and paste it into your page. It is free, needs no account, and the tool keeps working inside your page.

Related tools