Turn TypeORM entities into an ER diagram
Paste your TypeORM entity classes and get the tables they map to as DBML, with every @ManyToOne as a foreign key. Paste that into DB Planner and it is an ER diagram.
How entities become tables
@Entity()is a table, named by the decorator’s argument or itsnameoption, and by the class name when neither is given.@PrimaryGeneratedColumn()is an auto-incrementing key, and@PrimaryGeneratedColumn('uuid')auuidone.@PrimaryColumnis a key you assign yourself.@Columnis a column. Itstype,length,nullable, anduniqueoptions are read, and when the decorator names no type the TypeScript type fills it in: astringis avarchar, anumberanint.- The date columns TypeORM maintains, such as
@CreateDateColumn, are timestamps that default to now. @ManyToOneand an owning@OneToOneare a foreign key column and a reference to the target’s key, with theonDeleterule.
One picture for a schema spread across files
TypeORM puts each table in its own file, which is tidy to work in and awkward to review: understanding one relation means opening two files, and understanding the model means opening all of them. A diagram is the one place the whole schema is on screen together, and in DB Planner it stays editable as text, so a proposed change is a diff a teammate can read.
Other ORMs have the same converter here: Prisma and EF Core. To generate TypeScript row types or Zod schemas from a design, see the code generator.
TypeORM ER diagram questions
How do I generate an ER diagram from TypeORM entities?
Paste your entity classes above, one file after another, to get them as DBML. Paste the DBML into a DB Planner project and each entity is drawn as a table with its relations as lines.
My entities are in separate files. Do I paste them one at a time?
No, paste them all into the box together. A relation can only be drawn when both entities are present, so the files that reference each other need to be in the same paste. Import lines are ignored.
How is the foreign key column named?
By @JoinColumn({ name }) when you set it, and otherwise by TypeORM’s own default, the property name followed by Id. So an author relation with no join column becomes authorId.
Are @OneToMany relations drawn?
They are the other end of a @ManyToOne, which is the side that holds the foreign key column. The line is drawn once, from the column to the table it references.
Put your schema on the board
Start on the free plan, no card needed. Pro is $5 a month when you outgrow it.
Start designing free