Faker.Net is an open‑source mock test data generator library for .NET / C#. Inspired by the Ruby Faker ecosystem, it solves the common pain point of lacking large‑scale realistic test data during development debugging, database seeding and unit testing.
Project Repository:https://github.com/jonwingfield/Faker.Net
Quickly generate various realistic fake data for business scenarios, common categories:
- Personal info: full name, gender, phone number, email address, national ID
- Geographic info: province & city, full street address, postal code
- Business data: company name, job title, text snippet, date & time
- Network data: IP address, URL, username
Insert hundreds of test records with distinct names, genders and contact details into user tables without manual entry.
NuGet Package
Install-Package Faker.NetCode language: CSS (css)
Or via CLI
dotnet add package Faker.NetCode language: CSS (css)
Code Snippets
using Faker;
// Generate full name
string fullName = Name.FullName();
// Generate phone number
string phone = Phone.Number();
// Generate email address
string email = Internet.Email();
// Generate full physical address
string address = Address.FullAddress();Code language: JavaScript (javascript)
Bulk Data Generation Demo
// Loop to create 10 test user entries
var userList = new List<User>();
for (int i = 0; i < 10; i++)
{
userList.Add(new User()
{
Name = Name.FullName(),
Phone = Phone.Number(),
Email = Internet.Email(),
Address = Address.FullAddress()
});
}Code language: HTML, XML (xml)
Generate Random Names
Console App Example
static void Main(string[] args)
{
// Output 100 random English full‑names
for (int i = 0; i < 100; i++)
{
Console.WriteLine(Name.GetName());
}
Console.ReadKey();
}Code language: JavaScript (javascript)
Sample output: full names such as Bonnie Eichmann or Adrien Crooks. Some entries may include honorific prefixes (Miss, Mrs) or academic suffixes (PhD, IV).
Underlying Source‑Code Breakdown
public static class Name
{
public static string GetName()
{
// Get random integer from 0 to 9
switch (FakerRandom.Rand.Next(10))
{
// 10% chance: Prefix + Given name + Surname (Miss Deontae Mante)
case 0:
return GetPrefix() + " " + GetFirstName() + " " + GetLastName();
// 10% chance: Given name + Surname + Suffix (Haskell Morissette PhD)
case 1:
return GetFirstName() + " " + GetLastName() + " " + GetSuffix();
// Remaining 80%: Standard given‑plus‑surname format (Adrien Crooks)
default:
return GetFirstName() + " " + GetLastName();
}
}
// Pick one random first‑name from built‑in dataset
public static string GetFirstName()
{
return FIRST_NAMES.Rand();
}
}Code language: PHP (php)
Introduction