Getting Started


Faker is a popular library that generates fake (but reasonable) data that can be used for things such as:

  • Unit Testing
  • Performance Testing
  • Building Demos
  • Working without a completed backend

Faker was originally written in Perl and this is the JavaScript port. Language bindings also exist for Ruby, Java, and Python.

This documentation only covers the JavaScript implementation of Faker.


You can run Faker in the Browser, within Node, or the many other languages supported by Faker. (Perl, Ruby, Java, and Python)


Install it as a Dev Dependency using your favorite package manager.

npm install @faker-js/faker --save-dev


yarn add @faker-js/faker --dev


pnpm add @faker-js/faker --save-dev



import { faker } from '@faker-js/faker';

const randomName =; // Rowan Nikolaus
const randomEmail =; //


<script type="text/javascript" src=""></script>

  // Caitlyn Kerluke
  const randomName =;

  const randomEmail =;


Using the browser is great for experimenting 👍. However, due to all of the strings Faker uses to generate fake data, Faker is a large package. It's > 5 MiB minified. Please avoid deploying Faker in your web app.


import { faker } from '';

const randomName =; // Willie Bahringer
const randomEmail =; //


It is highly recommended to use version tags when importing libraries in Deno, e.g: import { faker } from "". Add ?dts to import with type definitions: import { faker } from "".



TypeScript Support

Since version v6+ there is native TypeScript support.

In order to have faker working properly, you need to check if these compilerOptions are set correctly in your tsconfig file:

  "compilerOptions": {
    "esModuleInterop": true,
    "moduleResolution": "Node"

And then simply import it like everything else:

import { faker } from '@faker-js/faker';

If you want for whatever reason the versions prior to v6, you can use @types/faker and rebind the declarations to the @faker-js/faker package with a faker.d.ts file in your e.g. src folder.

// faker.d.ts
declare module '@faker-js/faker' {
  import faker from 'faker';
  export default faker;


If you have questions or need help, reach out to the community via Discord and GitHub Discussions.