Handitab

JSON to TypeScript

Generate TypeScript interfaces from a sample JSON document, with nested objects turned into separate named interfaces and typed arrays.

About JSON to TypeScript

A TypeScript interface describes the shape of an object: its property names and their types. This tool walks a sample JSON value and infers string, number, boolean, or null for primitives, creates a named interface for every nested object (named after its key in PascalCase), and types arrays from their items, using a union when items differ. Types come from one sample only, so optional fields and wider unions must be added by hand.

Also known as: JSON to TS, JSON to TypeScript Converter, JSON to TypeScript Interface.

How to use JSON to TypeScript

  1. Type or paste into the "JSON" box, or press "Use example" to try it with sample data.
  2. Set "Root interface name" if the defaults do not fit.
  3. The result appears below and updates as you type.
  4. Copy the result with the copy button, or download it as a file where that is offered.

Questions about JSON to TypeScript

Why are no properties marked optional?

The generator sees a single sample and cannot know which fields may be absent, so every key present becomes required. If a field can be missing, add a question mark after its name in the generated interface.

Runs in your browser. Page last updated .

More developer tools

All 41 developer tools