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.

CREATE TABLE SQL
Generated ORM Model
Paste a CREATE TABLE statement above to generate the ORM model.

How to Use the SQL to ORM Generator

  1. Paste your CREATE TABLE SQL into the left panel — standard PostgreSQL, MySQL, SQLite, or SQL Server syntax.
  2. Choose your ORM — Sequelize (JavaScript/Node.js), GORM (Go), SQLAlchemy (Python), or Prisma.
  3. Copy or download the generated model and paste it into your project.
  4. 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, TEXTDataTypes.STRINGstringStringString
INT, INTEGER, SERIALDataTypes.INTEGERintIntegerInt
BIGINT, BIGSERIALDataTypes.BIGINTint64BigIntegerBigInt
BOOLEAN, BOOLDataTypes.BOOLEANboolBooleanBoolean
FLOAT, REAL, DOUBLEDataTypes.FLOATfloat64FloatFloat
DECIMAL, NUMERICDataTypes.DECIMALfloat64NumericDecimal
TIMESTAMP, DATETIMEDataTypes.DATEtime.TimeDateTimeDateTime
DATEDataTypes.DATEONLYtime.TimeDateDateTime
UUIDDataTypes.UUIDstringUUIDString @db.Uuid
JSON, JSONBDataTypes.JSONdatatypes.JSONJSONJson

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.

Frequently Asked Questions

The parser handles standard CREATE TABLE syntax as used in PostgreSQL, MySQL, SQLite, and SQL Server. It recognises common data types like VARCHAR, TEXT, INT, BIGINT, BOOLEAN, TIMESTAMP, DATE, FLOAT, DECIMAL, UUID, and JSON. Column constraints like NOT NULL, PRIMARY KEY, DEFAULT, UNIQUE, and AUTO_INCREMENT are also extracted.
No. All parsing and code generation runs entirely in your browser using JavaScript. Your SQL schema is never sent to any server, stored, or logged. This tool is 100% client-side.
Sequelize is a Node.js ORM for PostgreSQL, MySQL, MariaDB, SQLite, and SQL Server. GORM is the most popular ORM for Go. SQLAlchemy is the standard ORM for Python. Prisma is a TypeScript-first ORM with a schema-first approach and auto-generated client. Each has its own model definition syntax — this tool generates the correct boilerplate for each.
The generated code is starting-point boilerplate, not production-ready code. It maps standard SQL types to ORM equivalents and respects NOT NULL and PRIMARY KEY constraints. You will need to add relationships (associations/foreign keys), indexes, validation rules, hooks, and ORM-specific configurations manually.
Currently the tool processes the first CREATE TABLE statement found in the input. Paste each table separately to generate its model. Multi-table support with relationship inference is on the roadmap.