SQL to MikroORM Entity Converter

Convert SQL CREATE TABLE statements to MikroORM entity definitions with TypeScript decorators for PostgreSQL, MySQL, and SQLite.

What is SQL to MikroORM Entity Converter?

This tool converts SQL CREATE TABLE statements into MikroORM entity definitions. MikroORM is a TypeScript ORM for Node.js based on the Data Mapper, Unit of Work, and Identity Map patterns. The converter generates TypeScript classes with @Entity, @Property, and @PrimaryKey decorators for PostgreSQL, MySQL, or SQLite.

How to Use

  1. Select your database dialect (PostgreSQL, MySQL, or SQLite)
  2. Paste your SQL CREATE TABLE statements into the input area
  3. Click "Generate MikroORM Entity" to create the TypeScript entity classes
  4. Copy the output and save it as a .ts file in your MikroORM project

Why Use This Tool?

Automatically map SQL types to MikroORM property types
Handles PRIMARY KEY, NOT NULL, DEFAULT, REFERENCES, and UNIQUE constraints
Generates TypeScript classes with proper type annotations
Supports all three MikroORM dialects: PostgreSQL, MySQL, and SQLite

Tips & Best Practices

  • SERIAL columns are mapped with autoincrement: true
  • Foreign key references generate @ManyToOne decorators
  • TypeScript types are inferred from SQL column types
  • JSONB columns map to type "any" for flexible data structures

Frequently Asked Questions

What is MikroORM?

MikroORM is a TypeScript ORM for Node.js based on the Data Mapper, Unit of Work, and Identity Map patterns. It provides a clean and intuitive API for database operations with automatic transaction management and change tracking.

How are SQL types mapped to MikroORM types?

SQL types are mapped to MikroORM property types and columnType options. For example, VARCHAR maps to type string with columnType varchar, INTEGER maps to type number with columnType integer, TIMESTAMP maps to type Date.

Does it support relations?

Yes, REFERENCES constraints generate @ManyToOne decorators with the referenced entity type. You can manually add @OneToMany on the other side for bidirectional relations.

Is my SQL data sent to a server?

No, all processing happens entirely in your browser. Your SQL schema never leaves your device.

Related Tools