MySQL DDL to code
Parse CREATE TABLE (columns, types, length, NOT NULL, DEFAULT, AUTO_INCREMENT, PRIMARY KEY, COMMENT, UNSIGNED) into a Java bean (with optional Lombok/JPA annotations), TypeScript interface, Go struct or C# class, with a type mapping table and line-level error messages.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Type mapping
Mapping used by the generators; BIGINT is Long in Java or long with the primitives option
| MySQL | Java | Java primitive | TypeScript | Go | C# | Note |
|---|---|---|---|---|---|---|
| TINYINT | Byte | byte | number | int8 | sbyte | TINYINT(1) 视为布尔 |
| SMALLINT | Short | short | number | int16 | short | |
| MEDIUMINT | Integer | int | number | int32 | int | |
| INT | Integer | int | number | int32 | int | |
| INTEGER | Integer | int | number | int32 | int | |
| BIGINT | Long | long | number | int64 | long | |
| FLOAT | Float | float | number | float32 | float | |
| DOUBLE | Double | double | number | float64 | double | |
| DECIMAL | BigDecimal | BigDecimal | string | string | decimal | 用字符串避免精度丢失 |
| NUMERIC | BigDecimal | BigDecimal | string | string | decimal | |
| BIT | Boolean | boolean | boolean | bool | bool | |
| BOOL | Boolean | boolean | boolean | bool | bool | |
| BOOLEAN | Boolean | boolean | boolean | bool | bool | |
| CHAR | String | String | string | string | string | |
| VARCHAR | String | String | string | string | string | |
| TINYTEXT | String | String | string | string | string | |
| TEXT | String | String | string | string | string | |
| MEDIUMTEXT | String | String | string | string | string | |
| LONGTEXT | String | String | string | string | string | |
| JSON | String | String | string | string | string | |
| ENUM | String | String | string | string | string | |
| SET | String | String | string | string | string | |
| UUID | String | String | string | string | string | |
| BINARY | byte[] | byte[] | Uint8Array | []byte | byte[] | |
| VARBINARY | byte[] | byte[] | Uint8Array | []byte | byte[] | |
| TINYBLOB | byte[] | byte[] | Uint8Array | []byte | byte[] | |
| BLOB | byte[] | byte[] | Uint8Array | []byte | byte[] | |
| MEDIUMBLOB | byte[] | byte[] | Uint8Array | []byte | byte[] | |
| LONGBLOB | byte[] | byte[] | Uint8Array | []byte | byte[] | |
| DATE | LocalDate | LocalDate | string | time.Time | DateOnly | |
| TIME | LocalTime | LocalTime | string | string | TimeSpan | |
| DATETIME | LocalDateTime | LocalDateTime | string | time.Time | DateTime | |
| TIMESTAMP | LocalDateTime | LocalDateTime | string | time.Time | DateTime | |
| YEAR | Integer | int | number | int32 | int |
What this tool does
- Skip hand-writing entities at the start of a project: paste the whole CREATE TABLE and get a Java bean, TypeScript interface, Go struct or C# class with camelCased field names.
- Use it as a type-mapping reference: the MySQL → Java / TS / Go / C# table makes it easy to argue whether DECIMAL should be BigDecimal or string — just screenshot it.
- Fit an existing Lombok or JPA codebase: tick @Data or the jakarta.persistence annotations and the entity skeleton comes out with @Id, @GeneratedValue and @Column already in place.
- Find the typo in your DDL: parse failures report "Line N: reason", covering duplicated columns, unbalanced parentheses and unsupported constraint syntax, which is easier to read than a database error.
Example
Input
CREATE TABLE `t_user` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'primary key', `nickname` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'nickname', `balance` DECIMAL(10,2) NOT NULL DEFAULT 0.00, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `uk_nickname` (`nickname`) ) ENGINE=InnoDB COMMENT='Users';
Output
package com.example.demo;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
/**
* Users
*/
@Data
public class TUser {
/**
* primary key AUTO_INCREMENT
*/
private Long id;
/**
* nickname
*/
private String nickname;
private BigDecimal balance;
private LocalDateTime createdAt;
}The class name is the table name in PascalCase (t_user → TUser). The t_ prefix is not stripped automatically — enter t_ in "strip table prefix". Lombok is on by default, hence @Data and the lombok import.
Frequently asked questions
The table t_user produced TUser — how do I get User?
Put t_ in "strip table prefix" and that prefix is removed before PascalCasing. Alternatively type the exact class name in the class/struct name field, which takes priority over everything.
Why does DECIMAL become string in TypeScript?
DECIMAL and NUMERIC need decimal precision, and mapping them to a JS number loses it (the 0.1 + 0.2 problem). TypeScript and Go therefore carry the value as a string, Java uses BigDecimal and C# uses decimal.
Is TINYINT mapped to byte or to bool?
It depends on the length: TINYINT(1) is treated as boolean (Boolean in Java, boolean in TS, bool in Go), while other TINYINT columns map to an integer type (Byte in Java, as noted in the mapping table). Without a length it falls back to the integer mapping.
Why does it fail on CHECK, FULLTEXT or foreign keys?
The parser supports column definitions plus PRIMARY KEY / UNIQUE KEY / KEY fragments. CHECK constraints, FULLTEXT indexes and FOREIGN KEY clauses raise "unsupported definition fragment". Remove them and the columns and primary key still generate fine.
Do column comments and default values end up in the code?
Column comments go into Javadoc / doc comments, and AUTO_INCREMENT plus enum candidates are appended to that comment. Default values are only used during parsing, not emitted. The DDL is parsed locally and never uploaded.
Keywords:mysqlddlcreate tablejavabeanpojotypescriptgolangcsharplombokjpa建表语句代码生成