SQL Schema to TypeScript & ORM Converter

An interactive SQL schema parser and ORM code generator. Convert CREATE TABLE statements for PostgreSQL, MySQL, and SQLite into strongly-typed TypeScript interfaces, Prisma schemas, Drizzle ORM tables, Kysely interfaces, TypeORM entities, and Zod validation schemas.

How to Convert SQL Schemas to TypeScript & ORM Models

SQL Schema to TypeScript & ORM Converter parses CREATE TABLE DDL statements from PostgreSQL, MySQL, and SQLite dialects and instantly generates strongly-typed TypeScript interfaces, ORM models, and runtime validation schemas.

1. Supported Output Targets

  • TypeScript Interfaces: Clean, strongly-typed TypeScript interface declarations with strict nullability (string | null, optional fields, camelCase/snake_case mapping).
  • Prisma ORM (schema.prisma): Native Prisma model definitions including @id, @default(autoincrement()), @unique, @updatedAt, and @@map attributes.
  • Drizzle ORM: Ready-to-use Drizzle pgTable column definitions with chaining methods (.primaryKey(), .notNull(), .unique(), .defaultNow()).
  • Kysely: Strongly-typed Database interface and Generated<T> wrappers for auto-incrementing keys and timestamps.
  • TypeORM: Decorated class entities (@Entity(), @PrimaryGeneratedColumn(), @Column(), @CreateDateColumn()).
  • Zod Schemas: Runtime schema validation objects (z.object({...})) and inferred TypeScript types (z.infer<typeof schema>).

2. SQL Feature Recognition

  • Primary keys (PRIMARY KEY, SERIAL, AUTO_INCREMENT).
  • Nullability (NOT NULL, default nullable).
  • Unique constraints (UNIQUE).
  • Foreign key references (REFERENCES table(col)).
  • SQL Data Types: INT, BIGINT, VARCHAR, TEXT, BOOLEAN, TIMESTAMP, DATETIME, DECIMAL, FLOAT, UUID, JSON, JSONB.

Key Features

  • Multi-Target Code Generation: Convert SQL CREATE TABLE DDL directly into TypeScript interfaces, Prisma models, Drizzle ORM, Kysely, TypeORM, and Zod schemas.
  • Smart Constraint Recognition: Auto-detects PRIMARY KEY, AUTO_INCREMENT, SERIAL, NOT NULL, UNIQUE, DEFAULT, and REFERENCES foreign keys.
  • Case Conversion Options: Easily convert column names from snake_case to camelCase while keeping table mapping metadata intact.
  • Multi-Dialect Support: Compatible with PostgreSQL, MySQL / MariaDB, and SQLite DDL syntax.

Common Use Cases

  • Legacy Database Migration: Converting legacy relational database CREATE TABLE scripts directly into modern Prisma, Drizzle, Kysely, or TypeORM schemas.
  • Full-Stack Type Safety: Instantly generating TypeScript interfaces from SQL dump files for frontend and API route typing.
  • Runtime API Validation: Converting SQL table definitions into Zod validation schemas for validating API request bodies against database constraints.
  • ORM Switching & Evaluation: Comparing how database schema models look across different TypeScript ORMs (Prisma vs. Drizzle vs. Kysely vs. TypeORM).

Frequently Asked Questions

Does this tool process my database schema locally?

Yes! SQL parsing and model generation occur 100% inside your web browser. No database credentials or raw SQL schemas are sent to any external server.

Can I preserve my original SQL column names?

Yes! Toggle the Convert column names from snake_case to camelCase option on or off to choose between createdAt or created_at.

Related Tools