JSON to TypeScript

Generate TypeScript interfaces or type aliases from JSON.

JSON Input
TypeScript Output
TypeScript output appears here

Related Tools

Frequently Asked Questions

Interface vs type — which should I pick?

Both describe the same shape. interface is more common for object shapes and supports declaration merging; type is more flexible for unions and computed types. Pick whichever matches your codebase's convention.

When does a field become optional?

A field is marked optional (with ?) when its sample value is null, since the tool infers from a single example rather than scanning every array element for presence.

What's the difference between unknown and any?

unknown is the type-safe choice — you must narrow it before using it. any opts out of type checking entirely. Prefer unknown unless you have a specific reason not to.

How are nested objects named?

Each nested object gets its own named interface/type derived from its key (PascalCased), so deeply nested JSON produces multiple readable declarations instead of one giant inline type.

Does array element type get inferred correctly?

The tool infers the array's element type from its first item. Arrays with mixed element shapes across items aren't merged into a union — keep sample arrays representative.