SQL DDL to Code Generator
Turn CREATE TABLE statements into typed models for your language of choice — TypeScript interfaces, Prisma schema, Drizzle ORM, Go structs, JPA entities or SQLAlchemy classes. Nullability and column types are mapped for you, and nothing leaves your browser.
Do more than sql ddl to code generator — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Paste one or more CREATE TABLE statements from MySQL, PostgreSQL, SQL Server or SQLite.
- Choose the target language or ORM you want to generate models for.
- Copy the generated code into your project and adjust relations, which DDL alone cannot express.
Frequently asked questions
Which SQL dialects does the DDL parser understand?
The parser handles standard CREATE TABLE syntax plus the common dialect extensions: MySQL backticks and AUTO_INCREMENT, PostgreSQL SERIAL, BIGSERIAL, JSONB and GENERATED ... AS IDENTITY, SQL Server bracket quoting and UNIQUEIDENTIFIER, and SQLite type affinities. Table-level constraints such as PRIMARY KEY (a, b) and FOREIGN KEY clauses are skipped rather than treated as columns.
Why are DECIMAL and NUMERIC columns mapped to string in TypeScript?
JavaScript numbers are IEEE 754 doubles and cannot represent every decimal value exactly, so most drivers — including node-postgres and mysql2 — return NUMERIC and DECIMAL as strings to avoid silent rounding of monetary values. The generator follows that convention. Convert with a decimal library when you need arithmetic.
Does the generator create foreign key relations?
No. It generates the columns exactly as declared, including foreign key columns such as customer_id, but it does not infer ORM-level relation fields, because a single DDL statement does not tell you the cardinality or the name you want for the relation. Add the relation attributes manually after generating the models.
