JSONBeautify JSON Linter

Convert JSON to TypeScript Interfaces

JSON to TypeScript NEVER LEAVES YOUR BROWSER

Paste one JSON document and get an export interface for every object in it. Keys missing from some siblings become optional, arrays of objects become an interface for the element type, and values that disagree become a union.

JSON input
TypeScript
Options
What the generator can and cannot tell

More from JSONBeautify

Guides

All tools →All 13 guides →

Frequently Asked Questions

Why are some fields optional in the generated interface?

When an array holds objects and a key appears in only some of them, the generator marks it optional with a question mark. For [{"id":1,"name":"Ada"},{"id":2}], id is required and name is optional, because the second object has no name.

What type does an empty or mixed array get?

An empty array becomes unknown[], because there is nothing to infer from, so replace it with the real element type. An array that mixes types becomes a union: [1, "x"] gives (number | string)[]. Keys that are not valid identifiers, such as first-name, are quoted.

Developer Sponsor / Partner
Copied to clipboard!