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 / yearint32
int / integerint
bigintint64
varchar / char / text / tinytext / mediumtext / longtext / enum / set / timestring
datetime / timestamp / datetime.Time
decimal / numericfloat64
floatfloat32
double / realfloat64
jsonjson.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.