Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Const

generator

generator is a Prisma schema block that configures assets produced by prisma generate. For the current Prisma Client generator, set provider and the required output path.

How it works

In a Prisma schema, generator introduces a named generator block. The block selects the generator with provider and, for the current prisma-client generator, specifies the required destination with output; running prisma generate then creates the configured assets there.

Syntax

generator <name> {
  provider = "<generator-provider>"
  output   = "<output-path>"
}

Parameters

NameTypeDescription
providerstringSelects the generator implementation, such as the built-in Prisma Client generator.
outputstringRequired for prisma-client; path where generated Prisma Client code is written.

Returns

Generated assets, including customized Prisma Client code when the prisma-client provider is configured.

Key points

  • Generators describe the assets that Prisma should produce when prisma generate executes.
  • The selected generator controls what kind of generated output Prisma creates.
  • For prisma-client, output is mandatory and identifies the generated client's destination.
  • The prisma-client provider produces a database-specific Prisma Client for application code.

Common mistakes

  • With the current prisma-client generator, omitting output is invalid because the generated client destination must be explicit.

Example: Configure Prisma Client generation

generator client {
  provider = "prisma-client"
  output   = "./generated"
}

This schema block configures Prisma Client generation; run npx prisma generate from the project to create the client in the selected output directory.

When to use it

Prisma Client generation

Generate a typed database client for application code from the Prisma data model.

Multiple generated assets

Create outputs from more than one configured generator in a single schema.

Custom output location

Keep generated client code in a project-controlled directory by setting an explicit destination.

Interview questions

QWhat is the purpose of a generator block?

A generator block defines which assets Prisma creates when prisma generate runs. Its name is an identifier for the block, while provider selects the generator implementation.

Follow-up: How do you control where the generated client is written? Set the required output field to a path in the generator block.

QWhich fields are required for the current Prisma Client generator?

The current Prisma Client generator uses provider = "prisma-client". It also requires an output path, which determines where the generated Prisma Client code is placed.

Follow-up: What happens after configuration? Running prisma generate reads the schema and generates the customized client in that output directory.

QCan a Prisma schema define multiple generators?

A schema can contain one or more generators, and each generator determines assets produced by prisma generate. The command processes the generators defined in the schema.

Follow-up: How can a project use more than one generator? Add multiple named generator blocks, each configured for its own provider and supported options.

  • prisma-client
  • prisma-client-js
  • prisma generate
  • provider
  • output
  • datasource
  • data model

Source: Generators (Reference) (Prisma ORM v7). Checked 2026-10-16.