|
Developer Utilities 100% Client-Side · 0 Bytes Sent to Server Instant In-Memory Execution

SQL to TypeScript & Zod Generator

Accelerate your full-stack development by transforming raw SQL table definitions into type-safe TypeScript interfaces and Zod schemas. Supports PostgreSQL, MySQL, SQLite, and MariaDB DDL formats.

Generator Settings
SQL CREATE TABLE DDL
Generated TypeScript Types
Convert SQL DDL queries to TypeScript types and Zod schemas 100% locally.

Step-by-Step Instructions

1

Paste SQL CREATE TABLE Statements

Paste PostgreSQL, MySQL, SQLite, or SQL Server `CREATE TABLE` DDL statements.

2

Select Interface Options

Choose TypeScript `interface` vs `type`, configure nullable fields (`null` vs optional `?`), and set casing (snake_case vs camelCase).

3

Examine Generated TypeScript Interfaces

Review generated strongly-typed TypeScript definitions matching database column types.

4

Copy TypeScript Definitions

Copy generated types directly into your Next.js, Node.js, Express, or backend ORM codebase.

Key Features & Capabilities

  • Accurate SQL to TypeScript type mapping: `VARCHAR/TEXT` to `string`, `INT/FLOAT/DECIMAL` to `number`, `BOOLEAN/TINYINT(1)` to `boolean`, `TIMESTAMP/DATE` to `Date | string`, `JSON/JSONB` to `Record<string, any>`
  • Automatic handling of `NOT NULL` constraints and nullable column types (`string | null`)
  • CamelCase property conversion with optional original column comment preservation
  • Multi-table schema conversion supporting complex schemas with foreign key references

Frequently Asked Questions

How do SQL column data types map to TypeScript types?

**Text/Strings**: `VARCHAR`, `TEXT`, `CHAR`, `UUID` map to `string`; **Numbers**: `INT`, `BIGINT`, `FLOAT`, `DOUBLE`, `DECIMAL`, `REAL` map to `number` (or `bigint`); **Booleans**: `BOOLEAN`, `BIT`, `TINYINT(1)` map to `boolean`; **Dates**: `TIMESTAMP`, `DATETIME`, `DATE` map to `Date` or `string`; **JSON**: `JSON`, `JSONB` map to `Record<string, unknown>`.

How are NULL and NOT NULL constraints handled in TypeScript generation?

Columns with a `NOT NULL` constraint are typed as non-nullable primitive types (e.g., `email: string`). Columns that permit NULL values are typed as union types (e.g., `bio: string | null`) or optional properties (`bio?: string`), matching exact database runtime constraints.

Does the generator support PostgreSQL ENUM types?

Yes. Custom PostgreSQL `CREATE TYPE status AS ENUM ('active', 'pending', 'inactive');` statements are converted into native TypeScript union types (`type Status = 'active' | 'pending' | 'inactive';`).

Can I convert snake_case database columns into camelCase TypeScript properties?

Yes. You can toggle camelCase conversion (e.g., converting database column `created_at` to TypeScript property `createdAt`) for seamless integration with frontend JavaScript naming conventions.

Discover complementary online tools in the same workflow.