webutilkit

JSON to TypeScript Interface

Generate TypeScript interfaces from a sample JSON object, entirely in your browser.

TypeScript

How it works

Each value in the JSON is inspected to infer its TypeScript type: strings, numbers, and booleans map directly, arrays become T[] (or a union if they mix types), and nested objects become their own named interface, referenced from wherever they appeared.

A starting point, not a schema

This generates types from one example, so it cannot know whether a field is truly always present, or whether a number might sometimes be null in data you have not shown it. Treat the result as a first draft to refine against your actual API contract or schema.

Common uses

Quickly scaffolding types for an API response you have example data for, without hand-writing every interface, or double-checking that the interface you already wrote matches the shape of a real payload.

Frequently asked questions

How are nested objects handled?

Each nested object becomes its own named interface, named after the property that contained it, with the outer interface referencing it by name.

What if two different properties share the same name but different shapes?

Both generate an interface with that same name, and the second overwrites the first in the output. This tool is meant as a starting point for a single representative sample, not a full schema inference engine.