Infer TypeScript interfaces from JSON with deep nesting + optionals. Part of the DevTools Surf developer suite. Browse more tools in the Converters collection.
Use Cases
Generate TypeScript types from a live API response
Bootstrap a SDK from example payloads
Add typing to legacy endpoints without hand-writing interfaces
Convert webhook payload samples into strong-typed handler signatures
Tips
The output is a single root interface; nested objects become inline types
Union types are inferred from arrays of mixed elements
null fields are marked optional with the ? modifier
Fun Facts
TypeScript 4.1 added template-literal types, which let you derive string types from other string types at compile time.
TypeScript's type system is Turing complete — you can implement a full calculator or even a chess engine entirely within the type system.
Anders Hejlsberg, creator of TypeScript, also created Turbo Pascal, Delphi, and C# — four of the most influential programming languages in history.
FAQ
What's the output shape?
TypeScript interface and type alias definitions. Each nested JSON object becomes its own interface; arrays become `Type[]` with the inferred element type.
How does it detect optional fields?
Fields present in every sample record are required. Fields missing from any record get the `?` optional marker. Small samples may misclassify — review the output.
Does it handle unions?
Mixed-type values (sometimes string, sometimes number) become union types. `string | number` is common; more complex unions (discriminated) need manual cleanup.
Interface or type alias?
Both supported — toggle the output preference. Interfaces allow declaration merging; type aliases allow unions and mapped types. Pick per project convention.