Skip to main contentSkip to editor
SnipShiftSnipShift
JSinput.sql
Ready

SQL to TypeScript Converter

Generate TypeScript interfaces from SQL CREATE TABLE statements. AI-powered with smart type mapping, relation inference, and Prisma/Drizzle support.

How It Works

STEP 01

Paste Your SQL

Paste CREATE TABLE statements from PostgreSQL, MySQL, or SQLite. The editor provides real-time syntax highlighting and instant preview.

STEP 02

Click Convert

Our AI analyzes your schema, maps SQL types to TypeScript, detects foreign key relations, and generates precise interfaces or Prisma/Drizzle schemas.

STEP 03

Copy & Use

Copy the generated TypeScript types or download as a .ts file. Drop them into your project for instant type-safe database access.

Why Use This Tool

Type-Safe Database Access

Generated interfaces ensure your queries return exactly the types you expect catch schema mismatches at compile time, not in production.

Relation Inference

AI detects REFERENCES and FOREIGN KEY constraints, adding typed relation comments so you know how your tables connect.

Prisma & Drizzle Support

Beyond TypeScript interfaces, generate Prisma schema models or Drizzle ORM table definitions directly from your SQL.

Instant AST Preview

See TypeScript types update in real-time as you type SQL, powered by a regex-based parser that runs entirely in your browser.

Frequently Asked Questions

Which SQL dialects are supported?
PostgreSQL, MySQL, and SQLite. Each dialect handles its specific types SERIAL and JSONB for PostgreSQL, AUTO_INCREMENT and ENUM() for MySQL, and flexible typing for SQLite.
How accurate is the AI-generated output?
The AI understands SQL semantics and maps column types precisely. Foreign keys are detected from both inline REFERENCES and standalone CONSTRAINT declarations. Output is validated as compilable TypeScript before being returned.
What happens without AI?
The AST fallback generates correct TypeScript interfaces using regex-based SQL parsing. It handles all standard column types, NOT NULL constraints, PRIMARY KEY detection, and foreign key references. AI adds relation inference, Prisma/Drizzle generation, and enhanced type narrowing.
How are nullable columns handled?
Columns without NOT NULL are treated as nullable. You can choose between union-null style (column: string | null) or optional style (column?: string) in the options.
What is Select + Insert mode?
Select + Insert generates two types per table. The Select type includes all columns, while the Insert type makes auto-generated fields (id, created_at, columns with DEFAULT) optional matching how you actually insert rows.