Skip to main content
DevTools24

SQL to TypeScript

Convert SQL CREATE TABLE statements to TypeScript interfaces. Keep your types in sync with your database.

SQL to TypeScript Type Mapping:
INT/SERIAL → number
VARCHAR/TEXT → string
BOOLEAN → boolean
TIMESTAMP → Date
JSON/JSONB → Record
DECIMAL → number
UUID → string
BYTEA → Buffer

Database Type Safety - Technical Details

Generating TypeScript types from SQL schemas ensures your application code matches your database structure. Column types are mapped to TypeScript equivalents, and NULL columns become optional properties.

Command-line Alternative

-- SQL\nCREATE TABLE users (\n  id SERIAL PRIMARY KEY,\n  email VARCHAR(255) NOT NULL\n);\n\n// TypeScript\ninterface Users {\n  id: number;\n  email: string;\n}

Reference

View Official Specification