The faker.js ins and outs

Let’s fake it till we make it!

faker.js is a JavaScript library for generating a little or a lot of dummy data. Fake data can be used to build and test applications in the browser and node.js.

Demonstrated here are some example outputs of faker.js data, created to take the guess-work out of what your data could look like.

Setup

npm install faker in your project folder in the command line.

const faker = require(“faker”) in any project file you plan to use faker.js in.

faker.categoryName.dataName() to use any of the faker functions.

The categoryNames are above each chart and the dataNames are listed on the left side of the chart.

Anything with an *asterisk below will require an argument when called, otherwise simple () for invoking will suffice.

address

commerce

company

database

date

faker.fake()

Is a generator method for combining faker API methods that uses a mustache string formatted input.

Example:

faker.fake(“{{name.lastName}}, {{name.firstName}} {{name.suffix}}”)) => “Adams, Sean Sr.”

finance

git

hacker

helpers

image

internet

lorem

music

name

phone

random

system

time

vehicle

I hope these charts help to clarify any unknown outputs of faker.js. It is a very practical tool that can save you lots of time generating all the fake data you need.

Happy faking!

computer software engineer that graduated from Fullstack Academy