What is SQL to TypeScript Interface Generator?
This tool converts SQL CREATE TABLE statements into TypeScript interfaces, mapping SQL data types to their TypeScript equivalents. It supports PostgreSQL, MySQL, and SQLite syntax and handles nullable columns, default values, and multiple tables.
How to Use
- Configure the date type mapping (string or Date) and export keyword preference
- Paste your SQL CREATE TABLE statements into the input area
- Click "Generate TypeScript" to create the interfaces
- Copy the output and add it to your TypeScript project
Why Use This Tool?
Tips & Best Practices
- Use the "Date → string" option for API response types, "Date → Date" for ORM models
- The export keyword is enabled by default — disable it if you want to declare interfaces within a namespace
- DECIMAL and NUMERIC types map to number — for financial data, consider using a decimal library like decimal.js
- JSON and JSONB types map to Record<string, unknown> — you may want to replace with specific types
Frequently Asked Questions
How are SQL types mapped to TypeScript?
VARCHAR/TEXT → string, INTEGER/BIGINT/SERIAL → number, BOOLEAN → boolean, TIMESTAMP/DATE → Date or string, JSON/JSONB → Record<string, unknown>, UUID → string, BYTEA → Buffer.
Does it handle nullable columns?
Yes, columns without a NOT NULL constraint are generated as optional properties with the ? modifier.
Does it support multiple tables?
Yes, paste multiple CREATE TABLE statements and each one will generate a separate TypeScript interface.
Is my data sent to a server?
No, all processing happens entirely in your browser. Your SQL schema never leaves your device.