JSON to TypeScript

Generate a TypeScript interface from a JSON sample, with nested objects lifted into their own named types and optional fields detected. Your file never leaves this page. Everything happens in your browser, and there is no upload endpoint to send it to — that is checked by a build gate that fails if any network code reaches a tool’s bundle.

How to do it

  1. Paste a sample of your JSON.
  2. Give the type a name.
  3. Press Copy.

Questions

What can a sample not tell you?

Three things, and each is marked rather than guessed at. A field that is null in your sample might always be null or might sometimes hold a value. An empty list says nothing about what goes in it. And a single object cannot show which fields are optional — though an array of several can, and that is used.

How does it know a field is optional?

From evidence. Give it an array of records where one lacks a field, and that field is marked optional, because it is genuinely present in some and absent in others.

Is my JSON uploaded?

No. The whole thing runs in your browser.

Related tools

Browse every tool