Generating Fake Data in Node.JS

Each month I like to do a few courses on Udemy to sharpen my skills.

Recently, I was working through Stephen Grider’s Microservices with Node JS and React and it used a package for generating sample data.

The package is called Faker, a useful utility for generating sample data for entities such as Address, Company, Images, etc.

To install on Node:

npm install faker

To generate fake data:

var faker = require('faker');

var randomName = faker.name.findName();
var randomEmail = faker.internet.email();
var randomCard = faker.helpers.createCard(); // random contact card

You may also access via an API call only:

The full list of properties can be found here.

If you are a .NET developer, there is also a port of this popular library via nuget: https://www.nuget.org/packages/Faker.Net/

About the author

For the past two decades, Scott McCulloch has worked with a variety of distributed computing technologies. He is currently focused on cloud-native applications.