---
url: /plugins/plugin-faker.md
description: >-
  Generates a Faker.js mock-data factory for every schema in your OpenAPI spec.
  Use the factories in tests, Storybook, and local development without a running
  backend.
---

# @kubb/plugin-faker

`@kubb/plugin-faker` builds a mock-data factory for every schema in your OpenAPI spec with [Faker.js](https://fakerjs.dev/). Call `createPet()` to get a realistic `Pet` object. Use the factories in tests, Storybook stories, and local development without a backend.

## Installation

::: code-group

```shell [bun]
bun add -d @kubb/plugin-faker
```

```shell [pnpm]
pnpm add -D @kubb/plugin-faker
```

```shell [npm]
npm install --save-dev @kubb/plugin-faker
```

```shell [yarn]
yarn add -D @kubb/plugin-faker
```

:::

## Dependencies

This plugin depends on [`@kubb/plugin-ts`](/plugins/plugin-ts/) for the types each factory returns. Keep `pluginTs()` in the plugins array. No other plugin is required.

> \[!IMPORTANT]
> The generated factories need Faker v9 or higher.

## Example

::: code-group

```typescript twoslash [kubb.config.ts]
import { defineConfig } from 'kubb'
import { pluginFaker } from '@kubb/plugin-faker'
import { pluginTs } from '@kubb/plugin-ts'

export default defineConfig({
  input: './petStore.yaml',
  output: { path: './src/gen' },
  plugins: [
    pluginTs({
      output: { path: './types' },
    }),
    pluginFaker({
      output: { path: './mocks' },
      seed: [100],
    }),
  ],
})
```

:::

## See also

* [Faker.js](https://fakerjs.dev/)
* [@kubb/plugin-ts](/plugins/plugin-ts/)
* [@kubb/plugin-msw](/plugins/plugin-msw/)
* [Changelog](https://github.com/kubb-labs/plugins/blob/main/packages/plugin-faker/CHANGELOG.md)
