JSON to TypeScript Interface Generator

Paste any JSON and instantly get TypeScript interface definitions. Supports nested objects, arrays, null values, optional fields, and export keyword.

TypeScript interfaces will appear here…

Frequently Asked Questions

How are TypeScript types inferred from JSON?

The tool inspects each JSON value at runtime and maps it to the closest TypeScript primitive: JSON strings become string, numbers become number, booleans become boolean, null becomes null, arrays become T[], and objects become named interfaces. Nested objects recursively generate their own interfaces.

What happens with null values?

A JSON field set to null is typed as string | null, since null in JSON typically represents an optional string or object field. If you enable 'Optional fields', the field will also get a ? modifier, making it string | null | undefined.

Can it handle deeply nested JSON?

Yes. The converter is fully recursive. Each nested object generates its own named interface, using the parent key name in PascalCase. For example, a key 'address' containing an object will generate an Address interface.

What is the difference between interface and type in TypeScript?

Both describe object shapes and are mostly interchangeable. Interfaces support declaration merging (you can reopen and extend them), while type aliases are more flexible (union types, mapped types, etc.). For plain data shapes from APIs, either works. This tool defaults to interface, which is idiomatic for object shapes.

Does it handle arrays correctly?

Yes. Arrays with a single element type produce T[] (e.g., string[]). Mixed-type arrays produce a union: (string | number)[]. Empty arrays produce unknown[] since the element type cannot be inferred without data.