Generate mock data based on your Prisma models
149
stars
125
commits
TypeScript
primary language
Jun 4, 2026
updated
Generated with Nano Banana Pro.
It's a Prisma Generator that uses faker.js to create realistic-looking fake data for your Prisma models. With this generator, you can quickly and easily create fake data for your Prisma models, without having to write barely any code.
Setup your Prisma project as usual (Get Started With Prisma)
Install this package
npm install -D prisma-generator-fake-datayarn add -D prisma-generator-fake-datapnpm install -D prisma-generator-fake-databun add -D prisma-generator-fake-dataModify your Prisma model file
generator custom_generator {
provider = "prisma-generator-fake-data"
output = "../types/fake-data.ts"
}
Run npx prisma generate
You're all done!
If you prefer, you can easily get started with this CodeSandbox.
Once the file is generated, you can import it in your project.
generator client {
provider = "prisma-client-js"
}
generator custom_generator {
provider = "prisma-generator-fake-data"
/// by default, the file will be generated at `./prisma/fake-data.ts`
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String
/// Use comments to specify the faker method. For example:
///FAKE:faker.location.streetAddress({ useFullAddress: true })
address String
///FAKE:{notificationsEnabled: faker.datatype.boolean(), preferredColor: faker.color.rgb()}
settings Json
status UserStatus
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
someConfiguration Boolean
userId String @unique
user User @relation(fields: [userId], references: [id])
}
enum UserStatus {
active
inactive
}
import { fakeUser, fakeProfileComplete } from './prisma/fake-data'; //or your custom output path
console.log(fakeUser());
console.log(fakeProfileComplete());
/*
{
email: 'Ella.Mayer@gmail.com',
name: 'Lana Gulgowski',
age: 81,
settings: { notificationsEnabled: true, preferredColor: '#ee5344' },
maybeString: undefined,
status: 'active'
}
{
id: 96601,
someConfiguration: true,
userId: '821cf67a-dd86-49d7-b0e4-9ad451ad173d'
}
*/
| Option | Required | Default | Example | Description |
|---|---|---|---|---|
| output | no | "./fake-data.ts" | "../types/fake-data.ts" | Path where the file will be exported to. Base folder is your prisma folder. |
| extraImport | no | "" | "import {myCustomFunction} from '../utils/fakeImports'" | This import will be added to your generated file. Useful when you want to use a custom function to generate fake JSON data. You can use your TypeScript aliases. Base folder is your prisma folder. |
| extraExport | no | "" | "export * from '../utils/fakeImports'" | This export will be added to your generated file. Useful when you want to export all of the fake methods created by this generator from the same file. Base folder is your prisma folder. |
| emptyValueAs | no | "undefined" | "null" | By default, optional fields will be generated with undefined. You can change this behavior by overriding this parameter. You can use a function imported in extraImport or just pass a hardcoded value like "null". |
name, fullName, firstName, lastName, and age will use specific faker-js methods to appear more realistic.message String?), the fake data generator will always return undefined for that property (customizable through the emptyValueAs option).JSON Prisma field, you can add your own data shape by adding a special comment above your field.
///FAKE:{test: faker.lorem.word()}FAKE: string to your generated code, so it needs to be valid TypeScript.extraImport generator option, you can create your own helper methods to generate fake data for your JSON fieldsInspired by https://github.com/toyamarinyon/prisma-factory-generator
This generator was bootstrapped using create-prisma-generator
TypeScript
97.3%
JavaScript
1.8%
Generate mock data based on your Prisma models
149
stars
125
commits
TypeScript
primary language
Jun 4, 2026
updated
Generated with Nano Banana Pro.
It's a Prisma Generator that uses faker.js to create realistic-looking fake data for your Prisma models. With this generator, you can quickly and easily create fake data for your Prisma models, without having to write barely any code.
Setup your Prisma project as usual (Get Started With Prisma)
Install this package
npm install -D prisma-generator-fake-datayarn add -D prisma-generator-fake-datapnpm install -D prisma-generator-fake-databun add -D prisma-generator-fake-dataModify your Prisma model file
generator custom_generator {
provider = "prisma-generator-fake-data"
output = "../types/fake-data.ts"
}
Run npx prisma generate
You're all done!
If you prefer, you can easily get started with this CodeSandbox.
Once the file is generated, you can import it in your project.
generator client {
provider = "prisma-client-js"
}
generator custom_generator {
provider = "prisma-generator-fake-data"
/// by default, the file will be generated at `./prisma/fake-data.ts`
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String
/// Use comments to specify the faker method. For example:
///FAKE:faker.location.streetAddress({ useFullAddress: true })
address String
///FAKE:{notificationsEnabled: faker.datatype.boolean(), preferredColor: faker.color.rgb()}
settings Json
status UserStatus
profile Profile?
}
model Profile {
id Int @id @default(autoincrement())
someConfiguration Boolean
userId String @unique
user User @relation(fields: [userId], references: [id])
}
enum UserStatus {
active
inactive
}
import { fakeUser, fakeProfileComplete } from './prisma/fake-data'; //or your custom output path
console.log(fakeUser());
console.log(fakeProfileComplete());
/*
{
email: 'Ella.Mayer@gmail.com',
name: 'Lana Gulgowski',
age: 81,
settings: { notificationsEnabled: true, preferredColor: '#ee5344' },
maybeString: undefined,
status: 'active'
}
{
id: 96601,
someConfiguration: true,
userId: '821cf67a-dd86-49d7-b0e4-9ad451ad173d'
}
*/
| Option | Required | Default | Example | Description |
|---|---|---|---|---|
| output | no | "./fake-data.ts" | "../types/fake-data.ts" | Path where the file will be exported to. Base folder is your prisma folder. |
| extraImport | no | "" | "import {myCustomFunction} from '../utils/fakeImports'" | This import will be added to your generated file. Useful when you want to use a custom function to generate fake JSON data. You can use your TypeScript aliases. Base folder is your prisma folder. |
| extraExport | no | "" | "export * from '../utils/fakeImports'" | This export will be added to your generated file. Useful when you want to export all of the fake methods created by this generator from the same file. Base folder is your prisma folder. |
| emptyValueAs | no | "undefined" | "null" | By default, optional fields will be generated with undefined. You can change this behavior by overriding this parameter. You can use a function imported in extraImport or just pass a hardcoded value like "null". |
name, fullName, firstName, lastName, and age will use specific faker-js methods to appear more realistic.message String?), the fake data generator will always return undefined for that property (customizable through the emptyValueAs option).JSON Prisma field, you can add your own data shape by adding a special comment above your field.
///FAKE:{test: faker.lorem.word()}FAKE: string to your generated code, so it needs to be valid TypeScript.extraImport generator option, you can create your own helper methods to generate fake data for your JSON fieldsInspired by https://github.com/toyamarinyon/prisma-factory-generator
This generator was bootstrapped using create-prisma-generator
TypeScript
97.3%
JavaScript
1.8%