SQL to TypeScript types generator
Paste PostgreSQL CREATE TABLE statements and get TypeScript interfaces or Zod validation schemas, nullables, arrays, dates, and uuids mapped correctly.
export interface Users {
id: string;
email: string;
name: string;
created_at?: Date | null;
}
export interface Posts {
id: string;
user_id: string;
title: string;
body?: string | null;
created_at?: Date | null;
}
export interface Tags {
id: string;
name: string;
}
export interface Comments {
id: string;
post_id: string;
user_id: string;
content: string;
}
export interface PostTags {
post_id: string;
tag_id: string;
}
Frequently asked questions
How do PostgreSQL types map to TypeScript types?
integers, floats, and numerics become number; booleans become boolean; timestamps and dates become Date; text, varchar, and uuid become string; json and jsonb become unknown; bytea becomes Buffer; array columns become T[]. Nullable columns become optional properties (with | null) and Zod .nullable() schemas.
Is it free?
Yes, completely free with no signup. Everything runs in your browser, paste DDL, toggle between interfaces and Zod, copy the output.
Is my SQL uploaded anywhere?
No. Parsing and code generation run entirely in your browser. Your schema is never uploaded, stored, or logged.
Which PostgreSQL features are supported?
Tables, columns with full type strings, primary keys, nullability, and defaults. Foreign keys shape the diagram tools but do not change the generated types, relations are yours to model in your ORM.
Can I turn the result into an ER diagram?
Yes. Click Visualize this schema to open the same SQL in dbdiagramr as an interactive ER diagram, handy for checking the relationships behind the types you just generated.
Related tools
Turn it into an ER diagram
Paste your PostgreSQL connection string and get an interactive ER diagram of your own schema in under 10 seconds. No signup required.