Skip to content
ZeroServer.tools

TypeORM Entity Generator

Generate a TypeORM entity class with decorators from any JSON sample.

Preset Templates
Columns Inferred
7
Input Size
129 B
Output Size
465 B
Entity Name
User
Generated Entity Class
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from "typeorm";

@Entity()
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ unique: true })
  email: string;

  @Column({ nullable: true })
  firstName: string;

  @Column({ nullable: true })
  lastName: string;

  @CreateDateColumn()
  createdAt: Date;

  @Column({ default: false })
  isActive: boolean;

  @Column({ type: "float", nullable: true })
  score: number;
}

About TypeORM Entity Generator

Paste any JSON object and instantly generate a TypeORM entity class with the correct decorators, column types, and TypeScript property types. Supports @PrimaryGeneratedColumn, @Column, @CreateDateColumn, and @UpdateDateColumn out of the box. Customize the entity name, then copy or download the ready-to-use .ts file.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Generating an entity class from a sample row rather than typing every decorator.
  • Producing a starting entity for a table that has no model yet.
  • Getting the column decorator syntax right for a type you use rarely.
  • Seeing how nested data maps onto embedded columns or a relation.
  • Comparing a generated entity against an existing one to spot drift.

Frequently Asked Questions

What decorators does the generated entity use?
`@Entity()` on the class and `@Column()` on each property, with `@PrimaryGeneratedColumn()` for an inferred id. TypeORM reads those decorators at runtime to build its schema metadata, which is why the class is both your TypeScript type and your table definition.
Why does a date arrive as a string?
Because JSON has no date type — `"2026-01-01"` is just characters. The generator recognises the common ISO shapes and emits a `Date` column, but anything ambiguous stays a string. This is the field most worth checking by hand in any generated schema.
Does it infer relations between entities?
No — a single JSON sample shows nested objects but not whether they are separate tables. Nested structures become embedded columns or their own entities depending on what you intend, and `@OneToMany`/`@ManyToOne` need a decision about ownership that no example payload contains.
Should I use synchronize: true from this?
Only in development, never against a database with real data. TypeORM's synchronize drops and recreates columns to match the entity, which is exactly what you want on a scratch database and catastrophic on a production one. Generate migrations instead.
How are nullable columns decided?
They are not, reliably — a JSON sample where a field happens to have a value cannot show that it is sometimes absent. The generator marks what it can see, and every field that is genuinely optional in your domain needs `nullable: true` added deliberately.

Common errors and gotchas

  • Accepting inferred nullability, which one sample cannot determine and the database enforces.
  • Generating a scalar column where a relation was intended, which loses the foreign key entirely.
  • Letting a date string become a varchar, which then cannot be filtered by range.
  • Relying on synchronize to apply the entity, which is convenient in development and dangerous in production.
  • Omitting indexes and unique constraints, which are cheap now and painful on a large table later.

Related Developer Utilities tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate