Prisma Schema Field Types

All Prisma scalar types, relation types and native type modifiers with DB mapping.

Searchable Prisma schema field type reference covering scalar types (String, Int, BigInt, Decimal, DateTime, Json), enums, relations and @db native-type modifiers, with default PostgreSQL column mapping. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What scalar types does Prisma support?

Prisma's built-in scalars are String, Boolean, Int, BigInt, Float, Decimal, DateTime, Json and Bytes. Each maps to a sensible database column by default, which you can override with a @db native-type attribute.

Prisma schema field types

Every field in a Prisma model has a type: a built-in scalar, an enum, another model (a relation), or a composite type. Each scalar maps to a default database column that you can override with a @db native-type modifier. This searchable reference lists the scalar types, relation forms and native modifiers with their default PostgreSQL mapping so you can model schemas precisely.

Scalar types and their default PostgreSQL columns

Prisma scalarDefault PostgreSQL typeNotes
StringtextUse @db.VarChar(n) to cap length; email columns often use @db.VarChar(320)
Intinteger32-bit signed; for auto-increment PKs pair with @id @default(autoincrement())
BigIntbigint64-bit signed; for IDs expected to exceed ~2 billion
Floatdouble precisionIEEE 754 floating point; subject to rounding — never use for money
Decimaldecimal(65,30)Exact fixed-precision; the right choice for monetary amounts
BooleanbooleanStandard true/false
DateTimetimestamp(3)Millisecond precision; use @db.Timestamptz(3) to preserve timezone
JsonjsonbStores arbitrary JSON; cannot be deeply queried in a cross-database portable way
BytesbyteaBinary data; useful for file content, hashes, or binary blobs

How it works

A field is name Type modifiers attributes. Optionality and lists are encoded with ? and [], and native database types are set with @db:

model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique @db.VarChar(320)
  balance   Decimal  @db.Decimal(12, 2)
  createdAt DateTime @default(now()) @db.Timestamptz(3)
  metadata  Json?
  posts     Post[]
}

The Prisma scalar (String, Decimal, DateTime) chooses the default column, and the @db attribute pins the exact native type. Relations link models by referencing the related model type plus a @relation mapping.

Common mistakes to avoid

Using Float for money. Floating-point arithmetic cannot represent most decimal fractions exactly, so Float values accumulate rounding error across operations. Use Decimal for any monetary amount. For storage, @db.Decimal(12, 2) gives twelve total digits with two decimal places — enough for most currencies up to billions.

Forgetting @db.Timestamptz. Prisma’s default DateTime maps to timestamp(3) in PostgreSQL, which stores a point in time without any timezone information. If your application needs to preserve the timezone offset of an event (for example, a scheduled appointment in a user’s local zone), use @db.Timestamptz(3) so the database stores the timezone-aware value.

Making all string fields String without a length. The default text type has no practical length limit in PostgreSQL, which is fine for long fields. But for fields with a known maximum — email addresses, URLs, slugs — using @db.VarChar(n) communicates the constraint in the schema and the database enforces it as a safety check.

Tips and notes

  • Use Decimal (never Float) for money to avoid floating-point rounding.
  • DateTime defaults to timestamp(3); use @db.Timestamptz to store the zone.
  • Json is great for flexible blobs but cannot be deeply queried portably across databases.
  • Append ? for nullable and [] for list; BigInt maps to 64-bit integers.