免费在线 SQL DDL 转代码生成器。粘贴 CREATE TABLE 建表语句,一键自动转换为 Java (Lombok / MyBatis-Plus)、Go (GORM)、Python (Pydantic / SQLAlchemy) 及 TypeScript 实体类。自动提取字段注释与下划线转驼峰。
<!-- Options & Actions -->
<div class="flex items-center space-x-2 text-xs">
<label class="flex items-center space-x-1 text-slate-700 dark:text-slate-300 cursor-pointer">
<input type="checkbox" id="opt-camel" checked class="rounded border-slate-300 text-sky-600 focus:ring-sky-500">
<span>字段转小驼峰</span>
</label>
<label class="flex items-center space-x-1 text-slate-700 dark:text-slate-300 cursor-pointer">
<input type="checkbox" id="opt-comment" checked class="rounded border-slate-300 text-sky-600 focus:ring-sky-500">
<span>提取字段注释</span>
</label>
<button id="btn-load-ddl-sample" class="px-2.5 py-1 rounded border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-700 text-slate-700 dark:text-slate-200 transition-colors cursor-pointer">
加载建表示例
</button>
<button id="btn-clear-ddl" class="px-2 py-1 text-slate-500 hover:text-rose-600 dark:hover:text-rose-400 transition-colors cursor-pointer">
清空
</button>
</div>
<!-- Output Pane (Generated Code) -->
<div class="flex flex-col h-full bg-white dark:bg-slate-900">
<div class="px-4 py-2 border-b border-slate-100 dark:border-slate-800 text-xs font-semibold text-slate-500 flex justify-between items-center">
<span id="target-label">生成的 Java 实体类代码</span>
<div class="flex items-center space-x-2">
<button id="btn-copy-code" class="px-2.5 py-0.5 rounded border border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 font-medium transition-colors cursor-pointer flex items-center gap-1">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"/>
</svg>
<span id="copy-code-text">一键复制代码</span>
</button>
</div>
</div>
<div class="relative flex-1">
<textarea id="code-output" readonly spellcheck="false" placeholder="生成的代码将在此处实时展示..." class="w-full h-full min-h-[400px] p-4 font-mono text-xs sm:text-sm bg-slate-50/50 dark:bg-slate-950/40 border-0 focus:outline-none text-slate-800 dark:text-slate-100 resize-y leading-relaxed"></textarea>
</div>
</div>
本工具严格遵循行业工业级工程标准与 ORM 规范,为您处理 SQL 列类型到各目标语言的精准映射:
| SQL 数据类型 (MySQL / PG) | Java (Lombok) | Go (GORM) | Python (Pydantic) | TypeScript |
|---|---|---|---|---|
| BIGINT / BIGSERIAL | Long | int64 | int | number |
| INT / INTEGER / SERIAL | Integer | int32 | int | number |
| TINYINT(1) / BOOLEAN | Boolean | bool | bool | boolean |
| VARCHAR / CHAR / TEXT | String | string | str | string |
| DECIMAL / NUMERIC | BigDecimal | float64 | Decimal | number |
| DATETIME / TIMESTAMP | LocalDateTime | time.Time | datetime | Date |
| DATE | LocalDate | time.Time | date | string |
| JSON / JSONB | String | string | dict | Record<string, any> |