SQL to TypeScript Interface
Convert SQL CREATE TABLE DDL to TypeScript interfaces. Supports MySQL, PostgreSQL, SQLite.
What Is SQL to TypeScript Conversion?
SQL to TypeScript conversion transforms CREATE TABLE DDL (Data Definition Language) statements into TypeScript interfaces. This saves time when building full-stack applications — instead of manually mapping each column to a TypeScript type, you paste your schema and get type-safe interfaces instantly.
How to Use
- Paste your SQL
CREATE TABLEstatements into the input box - Toggle camelCase to convert snake_case column names to camelCase fields
- Toggle All Optional to mark every field as
?(useful for partial update types) - Copy the generated TypeScript interfaces with one click
Features
- Supports MySQL, PostgreSQL, SQLite DDL syntax
- Maps 50+ SQL types to TypeScript primitives (number, string, boolean, Uint8Array, unknown)
- Automatic
NOT NULLdetection — non-nullable columns become required fields - Optional snake_case → camelCase field name conversion
- Multi-table support: converts all tables in one pass
- 100% browser-based — no data sent to any server
FAQ
How are nullable columns handled?
Columns without NOT NULL are treated as nullable and generated as optional fields (field?: type). Columns marked NOT NULL become required fields.
What TypeScript type does JSON map to?
Both JSON and JSONB (PostgreSQL) map to unknown. You can narrow this to a specific interface after generation if the JSON structure is known.
Can I convert multiple tables at once?
Yes. Paste multiple CREATE TABLE statements separated by semicolons and all tables will be converted to individual interfaces in a single output.
Are PRIMARY KEY and FOREIGN KEY constraints included?
No. Constraints like PRIMARY KEY, FOREIGN KEY, and INDEX are skipped — only column definitions are converted to TypeScript fields.