SQL to TypeScript Interface Generator

Convert SQL CREATE TABLE statements to TypeScript interfaces with proper type mappings for PostgreSQL, MySQL, and SQLite.

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

  1. Configure the date type mapping (string or Date) and export keyword preference
  2. Paste your SQL CREATE TABLE statements into the input area
  3. Click "Generate TypeScript" to create the interfaces
  4. Copy the output and add it to your TypeScript project

Why Use This Tool?

Automatically map 30+ SQL data types to TypeScript equivalents
Nullable columns become optional properties with the ? modifier
Multiple CREATE TABLE statements generate separate interfaces
Save hours of manual type definition when working with databases

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.

Related Tools