Farzi.js is a powerful JavaScript library designed to generate good quality of realistic fake data for both browser and Node.js environments. Ideal for testing and development purposes, Farzi.js offers a wide range of data types, including but not limited to names, addresses, phone numbers, and more.
Install farzi.js with npm
npm install farzi.js
Use ES6 Module Import to import the package
import farzi from 'farzi.js';
Use traditonal method (CommonJS)
const farzi = require('farzi.js');
It can generate Fake Name using two methods firstName()
and fullName()
const name = farzi.firstName();
console.log(name); //Adam
const name = farzi.fullName();
console.log(name); //Adam Smith
It can generate number by two methods getRange(min, max)
and getNumber(length)
const number = farzi.number.getRange(0, 100);
console.log(number); //4
console.log(number); //87
console.log(number); //45
const number = farzi.number.getNumber(10);
console.log(number); //6767897653
const number = farzi.number.getNumber(4);
console.log(number); //4587
const number = farzi.number.getNumber(2);
console.log(number); //23
Generate fake email using method email()
const email = farzi.email();
console.log(email); // [email protected]
console.log(email); // [email protected]
console.log(email); // [email protected]
Generate Fake Addresses using address()
const address = farzi.address.getFullAddress();
console.log(address); // 59596 Curry Shoals Clarkchester, IA 32671
const address = farzi.address.getCity();
console.log(address); // Nataliebury
const address = farzi.address.getState();
console.log(address); // Utah
const address = farzi.address.getPostalCode();
console.log(address); // 97114
const address = farzi.address.getCountry();
console.log(address); // India
const address = farzi.address.getCountryCode();
console.log(address); // KG
Generate Fake Addresses using image()
Get random images using image(width, height)
Accepts width and height of the image and returns the image in specified size. (Leaving it blank will give the size of 400x400 px)
const image = farzi.image(250, 500);
console.log(image); // https://picsum.photos/250/500
const img = farzi.image();
console.log(img); // https://picsum.photos/400/400
Generate date and time using date
object.
It supports 3 methods i.e currentDate()
currentTime()
epochTime(type)
const date = farzi.date.currentDate();
console.log(date); // 2024-04-11T12:19:01.401Z
const time = farzi.date.currentTime();
console.log(time); // 5:50:29 PM
const epoch = farzi.date.epochTime('s');
console.log(epoch); // 1712838155
const epoch = farzi.date.epochTime('ms');
console.log(epoch); // 1712838149303
const epoch = farzi.date.epochTime();
console.log(epoch); // 1712838155
Generate fake card details using card()
method.
Get random fake card details using card()
method. No need to specify something here. It will automaticallly generate details such as Card Number, Card Owner Name, Expiry, CVV, Card Type.
const cardDetails = farzi.card();
console.log(cardDetails);
// {
"Card": "American Express",
"Owner Name": "Larry Chad",
"Card Number": 2402400982696908,
"expiry": "07/29",
"cvv": 444
}