Is your fake test data safe? We checked 100,000 Faker records
Faker's default emails all landed on gmail.com, yahoo.com or hotmail.com, 99% of its US phone numbers had a dialable shape and every card number passed the Luhn check. Here is what to use instead.
Fake data that looks real enough to test with is often real enough to reach someone. We generated 100,000 of each common field with @faker-js/faker 10.6.0, using its defaults, and checked where they point. Every default email was on gmail.com, yahoo.com or hotmail.com. 99% of the phone numbers had the shape of a dialable US number, and none were in the range set aside for fiction. Every card number passed the Luhn check. Faker has a safe option for emails. For phones and cards you have to choose the values yourself.
Everything below comes from examples/safe-fake-test-data. measure.mjs does the counting, run.sh runs it with three seeds, and results.txt is the raw output. Node 22.23.5, English locale. The three seeds agreed to within half a percentage point, so we quote seed 1.
Emails: all on real mail services
| Call | gmail.com | yahoo.com | hotmail.com | Reserved example domains |
|---|---|---|---|---|
faker.internet.email() | 33.5% | 33.1% | 33.4% | 0% |
faker.internet.exampleEmail() | 0% | 0% | 0% | 100% |
faker.internet.email() builds the local part from a first and last name, such as a first name, a dot and a surname, and puts it on one of three free mail services. Those are exactly the addresses real people have. If your staging server sends a password reset or a welcome email to seeded users, some of it can arrive in a stranger's inbox, and your sending domain collects the bounces and spam reports.
faker.internet.exampleEmail() uses example.com, example.net and example.org, which RFC 2606 reserves so they never belong to anyone. In our run it did that 100% of the time. Use it everywhere a seeded address could be mailed. If you need a domain of your own, .test is reserved by the same RFC.
Phone numbers: dialable, and none in the fiction range
Check on faker.phone.number() | Share |
|---|---|
| 10 digits, or 1 plus 10 digits | 100% |
| Valid North American shape (area code and exchange start with 2 to 9, no N11 area code) | 99.0% |
| In 555-0100 to 555-0199, the range set aside for fiction | 0% |
Samples looked like (487) 533-9977 and 1-470-486-1737 x5529. We can't tell which of these are assigned to someone, and many won't be. But almost all of them could be, and an SMS test that runs against a real gateway will try to deliver them.
North America sets aside 555-0100 through 555-0199 for fiction, in any area code. Faker has no option for that range in the version we tested, so build it yourself: pick an area code and append 555-01 plus two random digits. In the UK, Ofcom reserves ranges for drama, for example 07700 900000 to 07700 900999 for mobiles.
Card numbers: valid checksums with real brand prefixes
Check on faker.finance.creditCardNumber() | Share |
|---|---|
| Passes the Luhn check | 100% |
| Starts with a Visa, Mastercard, Amex, Discover, JCB or Diners prefix | 100%, about 16.7% each |
So every number has the right length, a real brand prefix and a valid checksum. That is what payment-data scanners look for. A log, a support export or an analytics event full of these looks like stored card data, and someone will have to prove it isn't.
Use the test numbers your payment provider publishes instead. Stripe's 4242 4242 4242 4242 is the best known. They are documented as test cards, every reviewer recognises them, and the provider's test mode gives them predictable outcomes, such as a decline or a 3D Secure challenge.
Names repeat less than you might think
In 10,000 draws of faker.person.fullName(), 20 names (0.2%) came up twice. That is low enough to forget about until a unique index on a name column fails in a big seed. Add a counter to the name if it must be unique.
What to do
- Emails: use
faker.internet.exampleEmail(), or your own address onexample.comor a.testdomain. Neverfaker.internet.email()in anything that can send mail. - Phones: generate inside 555-0100 to 555-0199 for the US and Canada, and the Ofcom drama ranges for the UK.
- Cards: use your payment provider's published test numbers, never generated ones.
- Seed with a fixed value (
faker.seed(1)) so a failing test gets the same data next time.
If you'd rather not write that code, our test data generators follow these rules already: the random email generator uses only RFC 2606 example domains, the random phone number generator stays in the fiction ranges, and test credit card numbers lists Stripe's published cards instead of generating any. The mock data generator makes whole rows as JSON, CSV or SQL in your browser.
Limits of this test
This is the English locale with default options. Other locales use other domains and number formats, so run measure.mjs with yours. We checked the shape of the phone numbers, not whether each one is in service.
Part of the team at Horizech — we build Flutter apps, AI integrations, web platforms, and games. If you want this done for you, get in touch.