Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@faker-js/faker

faker-js17.9mMIT9.4.0TypeScript support: included

Generate massive amounts of fake contextual data

faker, faker.js, fakerjs, faker-js, fake data generator, fake data, fake-data, fake-generator, fake-data-generator, fake content generator, fake contextual data generator, fake contextual data

readme

Faker

Generate massive amounts of fake (but realistic) data for testing and development.

npm version npm downloads Continuous Integration codecov Chat on Discord Open Collective sponsor

⚡️ Try it Online

Open in StackBlitz

📙 API Documentation

⚠️ You are reading the docs for the next branch ⚠️

Please proceed to the Getting Started 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

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

🪄 Usage

// 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) and v9.* (next).

Templates

Faker contains a generator method faker.helpers.fake for combining faker API methods using a mustache string format.

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.

// 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.

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.

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:

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 before making a pull request.

📘 Credits

Thanks to all the people who already contributed to Faker!

The fakerjs.dev website is generously hosted by Netlify, with search functionality powered by Algolia.

📝 Changelog

Detailed changes for each release are documented in the release notes.

📜 What happened to the original faker.js?

Read the team update (January 14th, 2022).

🔑 License

MIT

changelog

Changelog

All notable changes to this project will be documented in this file. See commit-and-tag-version for commit guidelines.

9.4.0 (2025-01-15)

Features

  • finance: use fake patterns for transactionDescription (#3202) (5ec4a6c)
  • internet: update to simplified modern user-agent list (#3324) (3c7abb5)
  • location: add list of spoken languages (#3333) (ff6dda9)

Changed Locales

  • locale: fix various locale data with trailing spaces (#3329) (e5eec0e)
  • locale: improve product_name data in en and tr (#3372) (773fc1f)

Bug Fixes

  • animal: re-moo-ved some incorrect cow data (#3326) (47f835b)
  • basic wildcard range handling + add more tests (#3322) (817f8a0)
  • finance: update Discover card number format to ensure accuracy (#3336) (69c0063)
  • image: dataUri should return random type (#3347) (eceb17d)
  • locales: update chemical element names in zh_CN (#3371) (6ec6f84)
  • location: fix bad uz street_name_part data (#3328) (b6132cb)
  • music: fix truncated song names with commas (#3327) (f36fc71), closes #996
  • system: semver parts should not be limited to 0-9 (#3349) (c0d92b8)

9.3.0 (2024-12-02)

Features

  • add initial seed parameter to constructors (#3220) (1633c8d)

Changed Locales

Bug Fixes

  • internet: ensure domainWord always returns a valid value in all locales (#3253) (525fedc)
  • locale: add Isadora to female names in pt_BR for consistency (#3282) (b390432)
  • locale: fix incorrect accents in it first_name (#3281) (e0fb23e)

9.2.0 (2024-11-03)

Features

Changed Locales

9.1.0 (2024-10-26)

New Locales

Features

Changed Locales

Bug Fixes

  • food: use arrayElement instead of fake for adjective (#3178) (a8dfa2f)
  • location: fix US ZIP code anomalies for zipCode({state}) (#3180) (df59724)
  • location: update valid ZIP ranges for FL and VA (#3167) (e271d4a)

9.0.3 (2024-09-26)

Changed Locales

  • locale: update french legal entity types (#3142) (d6bceb6)

Bug Fixes

  • image: fix dataUri with type svg-base64 in browsers (#3144) (78b2a3a)

9.0.2 (2024-09-23)

Bug Fixes

  • locale: improve pt_PT location and person data (#3020) (3e47ee7)

9.0.1 (2024-09-14)

Bug Fixes

9.0.0 (2024-09-02)

No noteworthy changes to 9.0.0-rc.1

For those upgrading from earlier versions, please refer to our Migration Guide for detailed instructions.

9.0.0-rc.1 (2024-08-19)

New Locales

  • locale: implement company info on pt_PT locale (#3022) (0fd0402)
  • locale: implement more colors to pt_PT locale (#3021) (a210619)
  • locale: implement state info on sk locale (#3054) (8c55493)

Features

9.0.0-rc.0 (2024-07-11)

Changed Locales

9.0.0-alpha.1 (2024-06-22)

⚠ BREAKING CHANGES

  • date: separate timeZone method (#2947)
  • locale: use singular locale definition keys (#2932)
  • locale: use snake case for all locale data (#2910)
  • locale: remove location data index-value-binding (#2476)

New Locales

Features

  • bitcoinAddress: multiple bitcoin address types and testnet (#2922) (3ae9393)
  • date: separate timeZone method (#2947) (d6924f7)
  • music: add album and artist methods (#2620) (f682750)

Changed Locales

Bug Fixes

9.0.0-alpha.0 (2024-04-12)

⚠ BREAKING CHANGES

  • locale: remove unused global locale faker instance (#2789)
  • locale: remove deprecated locale aliases (#2787)
  • date: birthdate improvements (#2756)
  • date: stricter error handling of between (#2719)
  • date: fail on invalid dates (#2757)
  • location: remove v8 deprecated location methods (#2753)
  • remove v8 deprecated type aliases (#2754)
  • commerce: remove v8 deprecated commerce method (#2752)
  • location: remove default_country definitions (#2740)
  • helpers: remove v8 deprecated helpers methods (#2729)
  • number: remove v8 deprecated number parameter (#2738)
  • company: remove v8 deprecated company methods (#2726)
  • phone: add new style parameter (#2578)
  • finance: remove v8 deprecated finance methods (#2727)
  • git: remove v8 deprecated git method (#2716)
  • phone: remove v8 deprecated phone format (#2712)
  • date: remove v8 deprecated date methods (#2704)
  • helpers: stricter checking for function signature passed to multiple (#2563)
  • internet: remove v8 deprecated internet methods (#2699)
  • random: remove v8 deprecated image methods (#2697)
  • high precision random number generator (#2357)
  • person: flatten jobs definitions (#2505)
  • datatype: remove v8 deprecated datatype methods (#2694)
  • helpers: use const generics where possible (#2685)
  • random: remove deprecated random module (#2678)
  • remove v8 deprecated faker class parts (#2682)
  • helpers: remove v8 deprecated unique (#2661)
  • switch to tsup (#2391)
  • image: remove v8 deprecated providers (#2634)
  • image: randomize defaults (#2472)
  • deps: update dependency typescript to v5 (#1953)
  • drop NodeJS v14 and v16 support (#2121)

Features

Bug Fixes

infra

New Locales

  • locale: add location for uz_UZ_latin (#2775) (80730e9)
  • locale: add uzbek locale (uz_UZ_latin) (#2686) (f7471a2)
  • locale: extend Uzbek locale for commerce (#2750) (b6b18d7)
  • locale: extend Uzbek locale for date and color (#2724) (776a625)
  • locale: support street and street address for ja (#2193) (501f4b3)

Changed Locales

8.4.1 (2024-02-06)

  • JSDocs improvements

8.4.0 (2024-01-24)

Features

  • helpers: add support for complex intermediate types (#2550) (24482a3)
  • number: add parameter fractionDigits in float (#1855) (41d8778)
  • person: add job titles for fr (#2531) (ba28ab6)

Bug Fixes

  • finance: correct VG IBAN format (#2552) (b8049d1)
  • internet: username method to return value that always includes… (#2506) (0ee1c67)
  • locale: incomplete airline names in zh_CN (#2558) (5525b55)
  • number: improve float generation for precisions of form 10^-n (#2581) (39c715d)

8.3.1 (2023-11-14)

Bug Fixes

  • remove [@internal](https://github.com/internal) from module parent classes (#2548) (77f54ad)

8.3.0 (2023-11-14)

Features

Bug Fixes

  • date: ensures correct range for birthdate (#2535) (7ce8c28)
  • finance: maskedNumber has incorrect defaults (#2494) (e0ba50b)
  • locale: improve Swedish phone numbers format (#2520) (e4865df)

Changed Locales

  • locale: remove fr_CH data which is identical to fr (#2526) (fafcba4)

New Locales

8.2.0 (2023-10-14)

Features

Bug Fixes

New Locales

  • locale: add airline database science commerce and vehicle for zh_CN (#2395) (9c96c0a)
  • locale: add street_name to en_US, en_GB and en (#2371) (491d319)
  • locale: add unionpay credit card for zh_CN (#2338) (74eeccc)

8.1.0 (2023-09-19)

Features

Bug Fixes

  • helpers: prevent uniqueArray from hanging (#2239) (3dece09)
  • image: dataUri is not random (#2316) (a7d25fa)
  • locale: invalid date definitions (#2293) (3cecae9)
  • locale: limited ja first names without passing sex (#2190) (5de8874)
  • locale: remove continent from ja countries (#2194) (cdd162a)
  • locale: remove duplicated countries in ja locale (#2189) (785a38a)
  • location: avoid hyphenated surnames in city patterns (#2119) (7a4bb43)
  • location: Czech postcode format (#2268) (37898ca)
  • location: Dutch postal codes can never start with '0' (#2326) (f195e06)
  • location: Pad en_US ZIP codes left to 5 characters if needed (#2278) (0ca1e44)
  • remove unrelated from de_CH country codes (#2304) (aa1bb13)
  • test: fix imports for jsdocs example verification (#2281) (2fe1308)
  • test: typedoc signature test issues (#2280) (02fc7ca)

Changed Locales

New Locales

8.0.2 (2023-05-27)

Bug Fixes

  • git: limit need for Intl to specific method (#2172) (a5e73f8)
  • locale: en_HK last_name_patterns should be last_name_pattern (#2154) (03cc391)
  • locale: ro_MD city should be city_pattern (#2155) (c173150)

8.0.1 (2023-05-15)

8.0.0 (2023-05-11)

Bug Fixes

  • docs: fix faker v7 code example for locale migration (#2125) (b570461)
  • locales: add real cities for zu_ZA and af_ZA, update en_ZA city list (#2141) (ee8c97c)

8.0.0-beta.1 (2023-05-06)

Features

Bug Fixes

  • locale: el county should be city_name (#2106) (1cadfb9)
  • locale: remove incorrect and unused city_prefix/suffix for sk (#2117) (e094a5a)
  • locale: remove unrealistic fictional patterns in ne, ro, tr (#2120) (d9ec87e)
  • locale: rename city_prefix to city_name for en_NG, en_ZA, en_AU_ocker (#2111) (a0fb69d)
  • location: no leading zero on building number or secondary address (#2032) (a8dc7e0)
  • test: fix failing latitude test (#2116) (7f9e9df)

Changed Locales

New Locales

8.0.0-beta.0 (2023-04-29)

⚠ BREAKING CHANGES

  • location: rename definition city to city_pattern (#2094)
  • location: rename definition street to street_pattern (#2051)
  • helpers: remove default value from arrayElement (#2045)
  • location: zip code state (#1874)
  • finance: simplify account implementation (#1992)
  • locale: move title to metadata (#1978)

Features

Bug Fixes

Changed Locales

New Locales

  • finance: simplify account implementation (#1992) (de078de)
  • helpers: remove default value from arrayElement (#2045) (0564446)
  • location: rename definition city to city_pattern (#2094) (8cd1965)
  • location: rename definition street to street_pattern (#2051) (3529ef7)
  • location: zip code state (#1874) (8574125)

8.0.0-alpha.2 (2023-03-24)

Bug Fixes

New Locales

8.0.0-alpha.1 (2023-03-20)

⚠ BREAKING CHANGES

  • remove dynamic locale switching support (#1735)
  • company: rename bs to buzz (#1860)
  • location: countryCode use ISO-3166-1 (#1720)
  • number: default to high precision float (#1675)
  • locale: remove unused separator entry (#1731)

Features

Bug Fixes

Changed Locales

New Locales

8.0.0-alpha.0 (2022-12-24)

⚠ BREAKING CHANGES

  • company: remove hardcoded name fallback pattern (#1451)
  • date: unify signatures (#1534)
  • helpers: rewrite shuffle (#1521)
  • image: remove lorempixel (#1641)
  • image: rewrite module (#1477)
  • internet: ip now returns ipv4 and ipv6 (#1059)
  • locale: change en_IND to en_IN (#1448)
  • location: latitude/longitude returns number (#1064)
  • location: nearbyGPSCoordinate returns number tuple (#1061)
  • location: rename address module (#1469)
  • number: change float default params (#1642)
  • number: change int default params (#1643)
  • person: rename name module (#1445)
  • string: swap allowLeadingZeros default to true (#1602)
  • cleanup deprecations (#1440)
  • make mersenne internal (#1444)
  • upgrade node minimum target (#1494)

Features

Bug Fixes

7.6.0 (2022-10-12)

Features

Bug Fixes

  • finance: adjust min length of generated bitcoin address (#1384) (10aded2)
  • finance: fix typo in Belarusian Ruble's name (#1395) (fe214c3)
  • finance: Update Belarusian Ruble to new version (#1392) (526906f)
  • finance: update Venezuelan bolívar name and code (#1394) (0e65143)
  • finance: update Zambian Kwacha to new version (#1393) (115e859)
  • image: properly lock loremflickr.com images (#1396) (2539e6a)
  • improve default seed initialization (#1334) (925db3a)
  • locale: change id_ID name to Indonesian (#1401) (ec0181e)

7.5.0 (2022-08-29)

Features

Bug Fixes

7.4.0 (2022-08-08)

Features

  • add rodent breed on animal 'en' locale (#1136) (a65f1a2)
  • dev: add male_first_name,female_first_name, jp locale (#1217) (ad885ea)
  • image: add image via.placeholder provider (#1186) (00d4741)
  • locales.en: extend vehicle (#1102) (07a970f)
  • locales.pl: add pl translation for gender and binary gender (#1162) (22a050e)
  • system.fileName: file extension count (#1101) (968134c)
  • system.networkInterface: add networkInterface faker (#1133) (5979f82)

Bug Fixes

  • finance.bic: remove hardcoded elements and simplify function (#1171) (5a397e0)

7.3.0 (2022-06-20)

New & Noteworthy

  • Webpack v4 should now be supported 🚀

Features

Bug Fixes

7.2.0 (2022-06-06)

⚠ SOFT BREAKING CHANGES

  • always use https for loremflickr (#1034)
    • we removed the last parameter for image.imageUrl and always generate https urls

Features

Bug Fixes

  • 🇫🇷 fr and 🇨🇭 fr_CH 🎨 colors (#1007) (d96457e)

7.1.0 (2022-05-25)

Features

Bug Fixes

  • Luhn generation algorithms and tests (#980) (c95826f)
  • typescript: support module Node16/NodeNext (#1005) (8736c2a)

7.0.1 (2022-05-23)

Bug Fixes

7.0.0 (2022-05-23)

⚠ BREAKING CHANGES

  • remove faker default export (#799)
  • target es2020 (#848)
  • remove deprecations (#916)
  • get rid of export = (#849)
  • remove node v12 support (#850)
  • reorganize src folder (#909)

Features

Bug Fixes

  • empty array passed into helpers.arrayElements (#921) (100a1ea)
  • generate:locale: make the definition types extendible (#915) (984fbb4)
  • type exports for module NodeNext, Node16 (#979) (73db3a7)
  • typo in error message (#925) (3ea64ce)

build

6.3.1 (2022-05-02)

Bug Fixes

  • replace deprecated arrayElement calls (#903) (42d6795)

6.3.0 (2022-05-02)

Features

Bug Fixes

6.2.0 (2022-04-21)

Features

Bug Fixes

  • Maryland (MD) wrong postal code (#804) (4ac2a04)
  • use \n as default separator for lorem.paragraphs() (#783) (6a2d8fc)

6.1.2 (2022-04-04)

Features

Bug Fixes

  • datatype.number when min = max + precision, throw when max > min (#664) (0304120)
  • deterministic results for address.nearbyGPSCoordinate (#737) (bc7bd57)
  • random word fails on undefined (#771) (fb1b87e)
  • remove doubled extension in system.filePath (#300) (2532eb9)

6.1.1 (2022-03-28)

Bug Fixes

  • forgot to run pnpm run build

6.1.0 (2022-03-28)

WARNING: This build is broken due to missing build files. Please don't use this version!

Features

  • types: generate all locales index files with non-any types (#494) (b611ca1)
  • types: provide strong typing for locales 2 (#398) (419e9e2)

Bug Fixes

6.0.0 (2022-03-15)

Bug Fixes

6.0.0-beta.0 (2022-03-07)

Features

  • types: generate all locales index files with non-any types (#494) (b611ca1)
  • types: provide strong typing for locales 2 (#398) (419e9e2)

Bug Fixes

6.0.0-alpha.7 (2022-02-20)

Features

  • types: generate all locales index files with non-any types (#494) (b611ca1)
  • types: provide strong typing for locales 2 (#398) (419e9e2)

Bug Fixes

6.0.0-alpha.6 (2022-02-10)

Features

  • add chat.fakerjs.dev subdomain redirection to discord (#306) (32b4839)
  • auto generate/update locale files (#252) (df48704)
  • types: provide strong typing for locales (#363) (5e6754d)

Bug Fixes

  • improve internet tests and fix bug in domain name generation (#258) (c6f7aa9)
  • optional args on faker.finance.iban() (#431) (c71469c)
  • param can be optional (#381) (f8a95a1)
  • remove redundant precision from datatype.datetime options (#335) (9d5a7a2)
  • removed dead code and adjusted fileExt (#304) (471bc1d)
  • removed node v12 from the pipe (#309) (537f56e)
  • some return types (#307) (4ca61ca)

6.0.0-alpha.5 (2022-01-25)

Bug Fixes

6.0.0-alpha.4 (2022-01-24)

⚠ BREAKING CHANGES

  • support tree-shaking (#152)

Features

Bug Fixes

6.0.0-alpha.3 (2022-01-15)

Features

Bug Fixes

  • added missing keys into package.json (#148) (b20f80b)

6.0.0-alpha.2 (2022-01-14)

6.0.0-alpha.1 (2022-01-14)

6.0.0-alpha.0 (2022-01-07)

For changes prior to version v6, see the old changelog.