Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/faker-js/faker
Generate massive amounts of fake data in the browser and node.js
https://github.com/faker-js/faker
browser data fake faker javascript nodejs
Last synced: 1 day ago
JSON representation
Generate massive amounts of fake data in the browser and node.js
- Host: GitHub
- URL: https://github.com/faker-js/faker
- Owner: faker-js
- License: other
- Created: 2022-01-07T17:22:27.000Z (about 3 years ago)
- Default Branch: next
- Last Pushed: 2024-10-29T09:36:19.000Z (4 months ago)
- Last Synced: 2024-10-29T11:44:48.437Z (4 months ago)
- Topics: browser, data, fake, faker, javascript, nodejs
- Language: TypeScript
- Homepage: https://fakerjs.dev
- Size: 28.5 MB
- Stars: 12,670
- Watchers: 35
- Forks: 911
- Open Issues: 122
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome - faker-js/faker - Generate massive amounts of fake data in the browser and node.js (TypeScript)
- awesome-nodejs - faker.js - Generate massive amounts of realistic fake data in Node.js and the browser.  (Repository / Testing)
- awesome-web-cn - faker - 一个可以为你的 node.js 或者浏览器生成大量假数据的库 (Uncategorized / Uncategorized)
- awesome-github-star - faker - js | 10420 | (TypeScript)
- stars - faker-js/faker - Generate massive amounts of fake data in the browser and node.js (TypeScript)
- awesome-web-dev - faker
- awesome-faker - JavaScript - @faker-js/faker - Generate massive amounts of fake data in the browser and node.js. (Languages)
- awesome - faker-js/faker - Generate massive amounts of fake data in the browser and node.js (TypeScript)
README
![]()
Faker
Generate massive amounts of fake (but realistic) data for testing and development.
[](https://www.npmjs.com/package/@faker-js/faker)
[](https://npm-compare.com/@faker-js/faker/#timeRange=ALL)
[](https://github.com/faker-js/faker/actions/workflows/ci.yml)
[](https://codecov.io/gh/faker-js/faker)
[](https://chat.fakerjs.dev)
[](https://opencollective.com/fakerjs#section-contributors)
[](https://opencollective.com/fakerjs)## ⚡️ Try it Online
[Open in StackBlitz](https://fakerjs.dev/new)
## 📙 API Documentation
⚠️ You are reading the docs for the next branch ⚠️
Please proceed to the [Getting Started Guide](https://fakerjs.dev/guide/) for the **stable** release of Faker.
For detailed API documentation, please select the version of the documentation you are looking for.
| Version | Website |
| :---------: | :------------------------ |
| v9 (next) | https://next.fakerjs.dev/ |
| v9 (stable) | https://fakerjs.dev/ |
| v8 (old) | https://v8.fakerjs.dev/ |---
## 🚀 Features
- 🧍 Person - Generate Names, Genders, Bios, Job titles, and more.
- 📍 Location - Generate Addresses, Zip Codes, Street Names, States, and Countries!
- ⏰ Date - Past, present, future, recent, soon... whenever!
- 💸 Finance - Create stubbed out Account Details, Transactions, and Crypto Addresses.
- 👠 Commerce - Generate Prices, Product Names, Adjectives, and Descriptions.
- 👾 Hacker - “Try to reboot the SQL bus, maybe it will bypass the virtual application!”
- 🔢 Number and String - Of course, we can also generate random numbers and strings.
- 🌏 Localization - Pick from over 60 locales to generate realistic looking Names, Addresses, and Phone Numbers.> **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
// ESM
import { faker } from '@faker-js/faker';// CJS
const { faker } = require('@faker-js/faker');export function createRandomUser() {
return {
userId: faker.string.uuid(),
username: faker.internet.username(), // before version 9.1.0, use userName()
email: faker.internet.email(),
avatar: faker.image.avatar(),
password: faker.internet.password(),
birthdate: faker.date.birthdate(),
registeredAt: faker.date.past(),
};
}export const users = faker.helpers.multiple(createRandomUser, {
count: 5,
});
```## 💎 Modules
An in-depth overview of the API methods is available in the documentation for [v9 (stable)](https://fakerjs.dev/api/) and [v9.\* (next)](https://next.fakerjs.dev/api/).
### Templates
Faker contains a generator method `faker.helpers.fake` for combining faker API methods using a mustache string format.
```ts
console.log(
faker.helpers.fake(
'Hello {{person.prefix}} {{person.lastName}}, how are you today?'
)
);
```## 🌏 Localization
Faker has support for multiple locales.
The main `faker` instance uses the English locale.
But you can also import instances using other locales.```ts
// ESM
import { fakerDE as faker } from '@faker-js/faker';// CJS
const { fakerDE: faker } = require('@faker-js/faker');
```See our documentation for a list of [provided languages](https://fakerjs.dev/guide/localization.html#available-locales).
Please note: Not every locale provides data for every module. In our pre-made faker instances,
we fall back to English in such a case as this is the most complete and most commonly used language.
If you don't want that or prefer a different fallback, you can also build your own instances.```ts
import { de, de_CH, Faker } from '@faker-js/faker';export const faker = new Faker({
locale: [de_CH, de],
});
```## ⚙️ Setting a randomness seed
If you want consistent results, you can set your own seed:
```ts
faker.seed(123);const firstRandom = faker.number.int();
// Setting the seed again resets the sequence.
faker.seed(123);const secondRandom = faker.number.int();
console.log(firstRandom === secondRandom);
```## 🤝 Sponsors
Faker is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome backers
### Sponsors

### Backers

## ✨ Contributing
Please make sure to read the [Contributing Guide](https://github.com/faker-js/faker/blob/next/CONTRIBUTING.md) before making a pull request.
## 📘 Credits
Thanks to all the people who already contributed to Faker!
The [fakerjs.dev](https://fakerjs.dev) website is generously hosted by [Netlify](https://www.netlify.com/), with search functionality powered by [Algolia](https://www.algolia.com/).
## 📝 Changelog
Detailed changes for each release are documented in the [release notes](https://github.com/faker-js/faker/blob/next/CHANGELOG.md).
## 📜 What happened to the original faker.js?
Read the [team update](https://fakerjs.dev/update.html) (January 14th, 2022).
## 🔑 License
[MIT](https://github.com/faker-js/faker/blob/next/LICENSE)