SQL to TypeORM Entity Converter

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

What is SQL to TypeORM Entity Converter?

This tool converts SQL CREATE TABLE statements into TypeORM entity definitions. TypeORM is a popular TypeScript ORM that supports both Active Record and Data Mapper patterns. The converter generates TypeScript classes with @Entity and @Column 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 TypeORM Entity" to create the TypeScript entity classes
  4. Copy the output and save it as a .ts file in your TypeORM project

Why Use This Tool?

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

Tips & Best Practices

  • SERIAL columns are mapped to @PrimaryGeneratedColumn()
  • Foreign key references generate @ManyToOne and @JoinColumn decorators
  • TypeScript types are inferred from SQL column types
  • JSONB columns map to type "any" for flexible data structures

Frequently Asked Questions

What is TypeORM?

TypeORM is a TypeScript ORM that supports both Active Record and Data Mapper patterns. It uses decorators to define entity classes and provides a powerful query builder for database operations.

How are SQL types mapped to TypeORM types?

SQL types are mapped to TypeORM column types based on the selected dialect. For example, VARCHAR maps to varchar, INTEGER maps to integer, TIMESTAMP maps to timestamp. Each column gets appropriate TypeScript type annotations.

Does it support relations?

Yes, REFERENCES constraints generate @ManyToOne decorators with @JoinColumn. 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