Faker
Generate massive amounts of fake (but realistic) data for testing and development.
[![npm version](https://badgen.net/npm/v/@faker-js/faker)](https://www.npmjs.com/package/@faker-js/faker)
[![npm downloads](https://badgen.net/npm/dm/@faker-js/faker)](https://www.npmjs.com/package/@faker-js/faker)
[![Continuous Integration](https://github.com/faker-js/faker/actions/workflows/ci.yml/badge.svg)](https://github.com/faker-js/faker/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/faker-js/faker/branch/main/graph/badge.svg?token=N61U168G08)](https://codecov.io/gh/faker-js/faker)
[![Chat on Discord](https://img.shields.io/badge/chat-discord-blue?style=flat&logo=discord)](https://chat.fakerjs.dev)
[![Open Collective](https://img.shields.io/opencollective/backers/fakerjs)](https://opencollective.com/fakerjs#section-contributors)
[![sponsor](https://img.shields.io/opencollective/all/fakerjs?label=sponsors)](https://opencollective.com/fakerjs)
## ⚡️ Try it Online
[![](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://fakerjs.dev/new)
[API Documentation](https://fakerjs.dev/guide/)
## 🚀 Features
- 💌 Addresses - Generate valid looking Addresses, Zip Codes, Street Names, States, and Countries!
- ⏰ Time-based Data - Past, present, future, recent, soon... whenever!
- 🌏 Localization - Set a locale to generate realistic looking Names, Addresses, and Phone Numbers.
- 💸 Finance - Create stubbed out Account Details, Transactions, and Crypto Addresses.
- 👠 Products - Generate Prices, Product Names, Adjectives, and Descriptions.
- 👾 Hacker Jargon - “Try to reboot the SQL bus, maybe it will bypass the virtual application!”
- 🧍 Names - Generate virtual humans with a complete online and offline identity.
- 🔢 Numbers - Of course, we can also generate random numbers and strings.
> **Note**: Faker tries to generate realistic data and not obvious fake data.
> The generated names, addresses, emails, phone numbers, and/or other data might be coincidentally valid information.
> Please do not send any of your messages/calls to them from your test setup.
## 📦 Install
```bash
npm install --save-dev @faker-js/faker
```
## 🪄 Usage
```ts
import { faker } from '@faker-js/faker';
// import { faker } from '@faker-js/faker/locale/de';
export const USERS: User[] = [];
export function createRandomUser(): User {
return {
userId: faker.datatype.uuid(),
username: faker.internet.userName(),
email: faker.internet.email(),
avatar: faker.image.avatar(),
password: faker.internet.password(),
birthdate: faker.date.birthdate(),
registeredAt: faker.date.past(),
};
}
Array.from({ length: 10 }).forEach(() => {
USERS.push(createRandomUser());
});
```
## 💎 Modules
An in-depth overview of the API methods is available in the [documentation](https://fakerjs.dev/guide/).
The API covers the following modules:
| Module | Example | Output |
| -------- | --------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| Address | `faker.address.city()` | Lake Raoulfort |
| Animal | `faker.animal.cat()` | Norwegian Forest Cat |
| Color | `faker.color.rgb()` | #cdfcdc |
| Commerce | `faker.commerce.product()` | Polo t-shirt |
| Company | `faker.company.companyName()` | Zboncak and Sons |
| Database | `faker.database.engine()` | MyISAM |
| Datatype | `faker.datatype.uuid()` | 7b16dd12-935e-4acc-8381-b1e457bf0176 |
| Date | `faker.date.past()` | Sat Oct 20 2018 04:19:38 GMT-0700 (Pacific Daylight Time) |
| Finance | `faker.finance.amount()` | ¥23400 (After setting locale) |
| Git | `faker.git.commitMessage()` | feat: add products list page |
| Hacker | `faker.hacker.phrase()` | Try to reboot the SQL bus, maybe it will bypass the virtual application! |
| Helpers | `faker.helpers.arrayElement(['a', 'b', 'c'])` | b |
| Image | `faker.image.cats()` | https://loremflickr.com/640/480/cats