Pydantic → TypeScript + Zod Converter

Paste your Pydantic models → get perfect TypeScript interfaces & Zod schemas instantly!
Supports nested models, Optional, List, Union, Literal, enums — everything!

Pydantic Models (Python)
TypeScript + Zod (Output)

            

About the Pydantic to TypeScript and Zod converter

Paste Pydantic models (classes that inherit from BaseModel). For each model, the tool writes a TypeScript interface, a matching Zod schema and an inferred type, so your frontend can share the backend's data shape.

Example

Input: class Address(BaseModel): with street: str, city: str, zip_code: Optional[str] = None

Output (excerpt):

export interface Address {
  street: string;
  city: string;
  zip_code?: string | null;
}
export const AddressSchema = z.object({
  street: z.string(),
  city: z.string(),
  zip_code: z.string().optional().nullable(),
});

Limits

  • Field mapping: str becomes string; int and float become number; bool becomes boolean; datetime becomes a string; List[...] becomes an array; Optional[...] becomes an optional field. Other names, including nested models, are kept as written.
  • The output does not include import { z } from "zod", so add it yourself.
  • Field(...) constraints, validators, unions written with |, and Enum classes are not fully converted. Check them by hand.
  • Each field must be on one line.

Privacy

All conversion happens in JavaScript inside your browser. The tool code on this page makes no network request with what you type, so your input is not uploaded or stored by PyInns. (The page itself still loads ads and shared libraries from third-party CDNs.)