Skip to content
iyziTool

JSON to TypeScript

Turn an API response or config file into TypeScript interfaces. Nested objects become named interfaces; keys missing from some array items become optional.

TypeScript
export interface Root { id: number; name: string; email: null; tags: string[]; address: Address; orders: Order[]; } export interface Order { id: number; total: number; note?: string; } export interface Address { city: string; zip: string; }

About this tool

Typing an API response by hand is tedious and error-prone. This generator walks the JSON, creates an interface for every object shape and names it after the key it lives under (singularised for arrays), infers primitive types, unions mixed array elements, and marks keys optional when they do not appear in every element of an array. Nulls become a null union so you remember to handle them.

The output is plain TypeScript with exported interfaces, ready to paste into a .d.ts or a module. Review the result: JSON cannot express that a string is actually a date or an enum, so refine those by hand.

Frequently asked questions

Why is a key marked optional?
It was present in some array elements but not all. That is the safest inference; remove the ? if your API guarantees it.
Can it generate type aliases instead of interfaces?
Objects become interfaces; the root becomes a type alias only when it is an array or primitive.
What about very large JSON?
Thousands of objects are fine. Only unique shapes produce interfaces.

Related tools