Getting Started
Overview
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. Faker is also available as a library for Ruby, Java, and Python.
This documentation only covers the JavaScript implementation of Faker.
Environments
You can run Faker in the browser, or in Node.js. Faker v10.0 requires Node.js version 20 or above.
Note
When using CJS, you need to use at least Node.js v20.19. See https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require
Installation
Install it as a Dev Dependency using your favorite package manager.
npm install @faker-js/faker --save-devpnpm add @faker-js/faker --save-devyarn add @faker-js/faker --devFaker Modules
Faker has three types of modules:
- Modules for basic datatypes:
datatype,date,numberandstring - Topic specific modules, such as
animal,foodand many more - Lastly, the
helpersmodule, with various utility methods to use with your own data (or data generated by other Faker methods)
For a full list of modules, go to our Api Search page.
If you would like to know how to use Faker, go to our Usage Guide page.
Community
If you have questions or need help, reach out to the community via Discord and GitHub Discussions.
You can see awesome things related to the Faker community at Awesome Faker.