TypeScript to Pydantic Converter

Generate Python Pydantic models from TypeScript interfaces for FastAPI

TS TypeScript
Py Pydantic Model

How It Works

1

Paste TypeScript

Enter your TypeScript interfaces with typed properties.

2

Click Convert

Our converter maps types to Pydantic Field types and generates models.

3

Get Python Code

Copy the Pydantic model for your FastAPI project or download as .py.

Type Mappings

TypeScript Type Pydantic Type Description
stringstrText values
numberint / floatNumeric values
booleanboolTrue/false values
anyAnyDynamic type
voidNoneNo return value
Array<T>List[T]Generic list
T | nullOptional[T]Optional field
interfaceBaseModelData model class
enumstr, EnumEnum with string values

Watch How It Works