Generate Test Data With Faker.js

Here is a common scenario for you. You’re building an application… any application. It could be your side project, a sales tool, an ecommerce site, a REST api, a video game, a reporting dashboard. Anything. You’re building your app, and you reach a point that you’d like to try it out, to see how it would look to a user. How do you simulate a production scenario with no data to test with? If you’re lucky, you have data from an existing customer you can use, or there is a sample dataset available online. If you’re unlucky, you’re left generating dummy data using garbage inputs (random strings, random numbers, etc) – data that passes the regex, but doesn’t provide a good simulation.

Do you wish there was a library that allowed you to programatically generate test data? Enter Faker.js. Faker.js allows you to generate a variety of data types in an intelligent and structured way. You can generate: Addresses, Products (Ecommerce), Companies, Dates, Images, URLs, and random objects as well (numbers, strings, words, uuid, etc). Click here to see a demo.

If you’d like to consume data from faker in another programming language, such as c#, you could use their hosted microservice at (i.e. A second option would be Bogus, a port of Faker for .net. There are ports available for other languages as well and the API surface is roughly the same in each instance.

I setup a very simple Github repo that demonstrates how to use Faker in a variety of scenarios to help you accomplish your goals. Hopefully you find this utility as useful as I do for prototyping new functionality before it goes into production.


Kyle Ballard

Software engineer specializing in Ecommerce.