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
- Select your database dialect (PostgreSQL, MySQL, or SQLite)
- Paste your SQL CREATE TABLE statements into the input area
- Click "Generate TypeORM Entity" to create the TypeScript entity classes
- Copy the output and save it as a .ts file in your TypeORM project
Why Use This Tool?
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.