fakeforge
v1.0.0
Published
Zero-dependency, seedable fake data generator — names, emails, phones, addresses and full person records for testing and prototyping.
Maintainers
Readme
fakeforge
Zero-dependency, seedable fake data generator for tests, demos, and prototypes. Generate names, emails, phone numbers, addresses, and full person records — with the option to make output fully reproducible.
Why another fake-data library?
- Zero dependencies — nothing to audit, tiny install.
- Seedable — pass a seed and you get the same data every run, so your test snapshots don't break.
- Simple API — one class, intuitive methods.
Install
npm install fakeforgeQuick start
const FakeForge = require('fakeforge');
const fake = new FakeForge();
fake.fullName(); // "Sofia Martinez"
fake.email(); // "[email protected]"
fake.phone(); // "(415) 892-3310"
fake.address(); // { street, city, state, stateAbbr, zip }
fake.person(); // full record (see below)Or grab the ready-made default instance:
const { fake } = require('fakeforge');
fake.fullName();Reproducible data with seeds
Pass a number or string seed. The same seed always produces the same sequence — ideal for deterministic tests.
const a = new FakeForge('my-seed');
const b = new FakeForge('my-seed');
a.fullName() === b.fullName(); // trueAPI
| Method | Returns |
| --- | --- |
| firstName() | First name |
| lastName() | Last name |
| fullName() | "First Last" |
| email(first?, last?) | Email, derived from a name if given |
| phone(format?) | Phone; format uses # as a digit placeholder |
| streetAddress() | "123 Maple St" |
| city() / state(abbr?) / zip() | Address parts |
| address() | { street, city, state, stateAbbr, zip } |
| number(min?, max?) | Integer in range |
| bool(probability?) | Boolean |
| pick(array) | Random item from your array |
| uuid() | v4-style UUID |
| date(start?, end?) | Date in range |
| words(n?) | n words of lorem ipsum |
| person() | Full person record |
| array(method, n, ...args) | Array of n results from a method |
Custom phone formats
fake.phone('+1-###-###-####'); // "+1-415-892-3310"
fake.phone('###.###.####'); // "415.892.3310"Generating many records
const users = new FakeForge('users').array('person', 100);
// 100 deterministic person objectsExample person record
{
"id": "a4e3c9e8-96c5-49ae-aa78-50692d103f9f",
"firstName": "Diego",
"lastName": "Davis",
"fullName": "Diego Davis",
"email": "[email protected]",
"phone": "(352) 762-6744",
"address": {
"street": "3432 Cedar Way",
"city": "Salem",
"state": "Georgia",
"stateAbbr": "GA",
"zip": "55495"
},
"birthDate": "1999-09-24"
}License
MIT
