SQL to ORM Model Generator
Paste a CREATE TABLE SQL statement to generate an ORM model for Sequelize, GORM, SQLAlchemy, or Prisma. 100% client-side.
How to Use the SQL to ORM Generator
- Paste your CREATE TABLE SQL into the left panel — standard PostgreSQL, MySQL, SQLite, or SQL Server syntax.
- Choose your ORM — Sequelize (JavaScript/Node.js), GORM (Go), SQLAlchemy (Python), or Prisma.
- Copy or download the generated model and paste it into your project.
- Customise — add relationships, validations, hooks, and index definitions that cannot be inferred from the table definition alone.
Why Use an ORM?
An Object-Relational Mapper (ORM) lets you interact with a relational database using your programming language's native objects and methods instead of writing raw SQL. ORMs handle parameterisation (preventing SQL injection), connection pooling, migration management, and often provide a query builder API. They improve developer productivity by keeping database access code in the same language and style as the rest of the application. Trade-offs include some performance overhead for complex queries and the need to learn the ORM's specific API — but for most CRUD-heavy web applications the productivity gains outweigh the costs.
SQL Type Mapping Reference
The following table summarises how this tool maps SQL column types to each ORM's equivalent:
| SQL Type | Sequelize | GORM (Go) | SQLAlchemy | Prisma |
|---|---|---|---|---|
| VARCHAR, TEXT | DataTypes.STRING | string | String | String |
| INT, INTEGER, SERIAL | DataTypes.INTEGER | int | Integer | Int |
| BIGINT, BIGSERIAL | DataTypes.BIGINT | int64 | BigInteger | BigInt |
| BOOLEAN, BOOL | DataTypes.BOOLEAN | bool | Boolean | Boolean |
| FLOAT, REAL, DOUBLE | DataTypes.FLOAT | float64 | Float | Float |
| DECIMAL, NUMERIC | DataTypes.DECIMAL | float64 | Numeric | Decimal |
| TIMESTAMP, DATETIME | DataTypes.DATE | time.Time | DateTime | DateTime |
| DATE | DataTypes.DATEONLY | time.Time | Date | DateTime |
| UUID | DataTypes.UUID | string | UUID | String @db.Uuid |
| JSON, JSONB | DataTypes.JSON | datatypes.JSON | JSON | Json |
Sequelize
Sequelize is the most widely used Node.js ORM, supporting PostgreSQL, MySQL, MariaDB, SQLite, and Microsoft SQL Server. Models are defined by calling sequelize.define() with a model name and an attributes object. Each attribute maps to a column and includes a DataTypes enum value plus optional constraint flags like allowNull, primaryKey, and unique. Associations (hasOne, hasMany, belongsTo, belongsToMany) are defined separately on the model. Migrations are managed with the Sequelize CLI (sequelize-cli). The generated boilerplate sets underscored: true and timestamps: false as sensible defaults — adjust these for your project conventions.
GORM
GORM is the Go ORM library and follows Go's struct conventions. Each model is a Go struct where fields map to columns. GORM uses struct tags (gorm:"...") to express constraints, column names, and foreign key relationships. The primary key is conventionally named ID or tagged with primaryKey. GORM includes an gorm.Model embedded struct that provides ID, CreatedAt, UpdatedAt, and DeletedAt fields automatically — the generated code embeds this when those columns are detected in the SQL. GORM supports auto-migration with db.AutoMigrate(&Model{}).
SQLAlchemy
SQLAlchemy is the Python SQL toolkit and ORM. The generated code uses the modern declarative base style with DeclarativeBase (SQLAlchemy 2.x) and Mapped[type] type annotations for columns. Each column is declared using mapped_column() with optional parameters for primary key, nullable, unique, and default values. SQLAlchemy supports Alembic for database migrations. The generated class name is a PascalCase version of the table name.
Prisma
Prisma is a TypeScript-first ORM with a schema-first workflow. Instead of defining models in application code, you define them in a schema.prisma file, then run prisma generate to produce a fully-typed client. The generated Prisma model block uses the table name and maps each SQL column to a field with a Prisma scalar type. The @@map directive links the model to the actual SQL table name when it differs from the model name. Run prisma db push or prisma migrate dev to apply the schema to your database.
Choosing the Right ORM for Your Project
For new Node.js projects with TypeScript, Prisma's type safety and developer experience are hard to beat. For existing Node.js projects that are already using Sequelize, stay with it — migration costs rarely justify switching. In Go, GORM is the de-facto standard and integrates well with gin, echo, and fiber. In Python, SQLAlchemy is the right choice for almost every project — FastAPI, Flask, and Django (via SQLAlchemy as an alternative to Django ORM) all work well with it. Whatever ORM you use, always review generated boilerplate carefully before committing — an ORM model is a contract between your application and your database schema. Use our SQL Formatter to clean up your SQL before pasting, or try the JSON to TypeScript generator for frontend type definitions.