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.
Step-by-Step Instructions
Paste SQL CREATE TABLE Statements
Paste PostgreSQL, MySQL, SQLite, or SQL Server `CREATE TABLE` DDL statements.
Select Interface Options
Choose TypeScript `interface` vs `type`, configure nullable fields (`null` vs optional `?`), and set casing (snake_case vs camelCase).
Examine Generated TypeScript Interfaces
Review generated strongly-typed TypeScript definitions matching database column types.
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.
Related Utilities
Discover complementary online tools in the same workflow.
JSON Formatter & Validator
Format, beautify, minify, validate, and view JSON data online with instant syntax highlighting and error detection.
Base64 Encoder & Decoder
Encode text or binary data into Base64 format or decode Base64 back into raw string format.
CSV to JSON Converter
Easily convert CSV data to clean JSON format. Turn tabular spreadsheets into structured JSON.
YAML to JSON Converter
Convert YAML configuration files into structured JSON for APIs and modern web tooling.
JWT Parser & Token Debugger
Decode JWT tokens to view header, payload claims, and expiration status without sending secrets anywhere.
Hash Generator (SHA-256, SHA-512, MD5)
Generate cryptographically secure SHA-256, SHA-512, SHA-384, and SHA-1 hashes for any text.