SQL to GORM
Paste MySQL CREATE TABLE statements and generate Go GORM model structs
Input
Output
Type Mapping Reference
| SQL (MySQL) | Go |
|---|---|
| tinyint(1) | bool |
| tinyint / smallint / mediumint / year | int32 |
| int / integer | int |
| bigint | int64 |
| varchar / char / text / tinytext / mediumtext / longtext / enum / set / time | string |
| datetime / timestamp / date | time.Time |
| decimal / numeric | float64 |
| float | float32 |
| double / real | float64 |
| json | json.RawMessage |
| binary / varbinary / blob / tinyblob / mediumblob / longblob | []byte |
tinyint(1) maps to bool; other tinyint columns map to int32. Unrecognized SQL types fall back to string and are marked with a comment in the generated code.
How to Use
Paste one or more MySQL CREATE TABLE statements into the input, toggle the options as needed and click "Generate" to get ready-to-compile Go GORM model code (package and imports included). Primary keys, auto-increment, NOT NULL, defaults, comments, unique and normal indexes are converted, and multiple statements produce multiple structs. Everything runs locally in your browser — your SQL is never uploaded.
Mapping Conventions
unsigned columns map to signed Go types (e.g. int unsigned → int); adjust to uint types manually if needed. date maps to time.Time, same as datetime/timestamp (switch to string by hand if you prefer a plain date). decimal/numeric map to float64, which has precision limits — for money and exact arithmetic prefer shopspring/decimal. json maps to json.RawMessage, and the encoding/json import is added automatically.