Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Generate massive amounts of fake data in the browser and node.js

License

NotificationsYou must be signed in to change notification settings

faker-js/faker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Faker

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

npm versionnpm downloadsContinuous IntegrationcodecovChat on DiscordOpen Collectivesponsor

⚡️ Try it Online

Open in StackBlitz

📙 API Documentation

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

Please proceed to theGetting Started Guide for thestable release of Faker.

For detailed API documentation, please select the version of the documentation you are looking for.

VersionWebsite
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

// ESMimport{faker}from'@faker-js/faker';// CJSconst{ faker}=require('@faker-js/faker');exportfunctioncreateRandomUser(){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(),};}exportconstusers=faker.helpers.multiple(createRandomUser,{count:5,});

💎 Modules

An in-depth overview of the API methods is available in the documentation forv9 (stable) andv9.* (next).

Templates

Faker contains a generator methodfaker.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 mainfaker instance uses the English locale.But you can also import instances using other locales.

// ESMimport{fakerDEasfaker}from'@faker-js/faker';// CJSconst{fakerDE:faker}=require('@faker-js/faker');

See our documentation for a list ofprovided 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';exportconstfaker=newFaker({locale:[de_CH,de],});

⚙️ Setting a randomness seed

If you want consistent results, you can set your own seed:

faker.seed(123);constfirstRandom=faker.number.int();// Setting the seed again resets the sequence.faker.seed(123);constsecondRandom=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 theContributing Guide before making a pull request.

📘 Credits

Thanks to all the people who already contributed to Faker!

Thefakerjs.dev website is generously hosted byNetlify, with search functionality powered byAlgolia.

📝 Changelog

Detailed changes for each release are documented in therelease notes.

📜 What happened to the original faker.js?

Read theteam update (January 14th, 2022).

🔑 License

MIT


[8]ページ先頭

©2009-2025 Movatter.jp