RandomNameGeneratorLibrary 2.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package RandomNameGeneratorLibrary --version 2.1.0
                    
NuGet\Install-Package RandomNameGeneratorLibrary -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RandomNameGeneratorLibrary" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RandomNameGeneratorLibrary" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="RandomNameGeneratorLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RandomNameGeneratorLibrary --version 2.1.0
                    
#r "nuget: RandomNameGeneratorLibrary, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RandomNameGeneratorLibrary@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RandomNameGeneratorLibrary&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=RandomNameGeneratorLibrary&version=2.1.0
                    
Install as a Cake Tool

DotNetRandomNameGenerator

Generates random people and place names drawn from freely available US census data.

NuGet CI

dotnet add package RandomNameGeneratorLibrary

Targets netstandard2.0 (any .NET Framework 4.6.2+, .NET Core, Mono, Unity) and net10.0, with no dependencies. Version 2.1 keeps the 1.2.2 / 2.0 API and adds seed constructors and read-only access to the lists; see CHANGELOG.md. Try it live at https://www.markdavidrogers.com/tools (random names) or through the site's MCP server tool random_name.

What the names look like

Eight of each, straight from the library. Each row comes from a fresh generator built with new Random(20260924) and one GenerateMultiple...(8) call, so you can reproduce them:

Kind Examples
First and last name Jon Rohl, Deneen Vanvolkinburg, Alona Glordano, Norris Veltz, Wes Tomopoulos, Peter Melito, Stephanie Niceswander, Erich Dunnagan
Female first name Hildegard, Laurel, Gertie, Jodee, Deneen, Margaretta, Margorie, Alona
Male first name Benny, Jon, Lowell, Quincy, Tyson, Winfred, Aurelio, Alonso
Last name Drouillard, Batres, Rohl, Tabar, Babilonia, Vanvolkinburg, Vendrick, Absalon
Place name Phillips, Nebo Center, Smithton, Mindenmines, Popponesset, Lyndhurst, Little Silver, Vega Baja zona urbana

The lists have their frequencies stripped, so every entry on a list is equally likely: common names and rare ones sit side by side, and a few first names appear on both the male and female lists because the census recorded them that way.

Usage

Create a PersonNameGenerator or PlaceNameGenerator in namespace RandomNameGeneratorLibrary and call a method such as GenerateRandomFirstAndLastName(). Every method name says literally what it does.

Generating a person name:

var personGenerator = new PersonNameGenerator();
var name = personGenerator.GenerateRandomFirstAndLastName();

Console.WriteLine(name); // "{first} {last}", for example "Mark Rogers"

Generating a place name:

var placeGenerator = new PlaceNameGenerator();
var name = placeGenerator.GenerateRandomPlaceName();

Console.WriteLine(name); // for example "Hoboken"

Male and female first names can be generated with or without a last name:

var personGenerator = new PersonNameGenerator();
var name = personGenerator.GenerateRandomFemaleFirstName();

Console.WriteLine(name); // for example "Jane"

More than one name can be generated at a time. There are methods for each gender and for last names alone, and each takes the number of names to produce:

var personGenerator = new PersonNameGenerator();
var names = personGenerator.GenerateMultipleFemaleFirstAndLastNames(5);

Console.WriteLine(names.First()); // for example "Rose Jones"

For reproducible names, pass a seed or your own Random:

var personGenerator = new PersonNameGenerator(42);           // same seed, same names
var another = new PersonNameGenerator(new Random(42));       // equivalent
var name = personGenerator.GenerateRandomFemaleFirstName();

Console.WriteLine(name); // for example "Lindsay"

The same functionality is available as extension methods on Random:

var randomObj = new Random(42);
var name = randomObj.GenerateRandomFemaleFirstName();
var place = randomObj.GenerateRandomPlaceName();

The lists themselves are exposed read-only, so you can count them or pick your own way:

Console.WriteLine(PersonNameGenerator.LastNames.Count);     // 88799
Console.WriteLine(PlaceNameGenerator.PlaceNames[0]);        // first entry of the place list

IPersonNameGenerator and IPlaceNameGenerator cover the generating methods, for dependency injection and for mocking in tests.

Thread safety

A generator made with the default constructor is safe to share between threads (it uses Random.Shared on .NET 6+ and a well-seeded Random per generator on .NET Framework). A generator made around your own Random, including the extension methods, is only as thread-safe as that Random, which is not at all: use one generator per thread. The lists are parsed once per process, on first use, and are safe to read from any thread.

Unity

The netstandard2.0 build works in Unity: no dependencies, no runtime reflection beyond reading its own embedded resources, and no runtime regular expressions. Copy the DLL from the package's lib/netstandard2.0 folder into Assets/Plugins, or use a NuGet-for-Unity tool.

Data

List Entries Source
Male first names 1,219 1990 US Census name frequency file dist.male.first
Female first names 4,275 1990 US Census name frequency file dist.female.first
Last names 88,799 1990 US Census name frequency file dist.all.last
Place names 16,873 Census 2000 places file places2k.txt, one entry per distinct name

Person names are ASCII and Title case (Mark, Rogers). The place list drops the state and the classification word (city, town, CDP, ...), keeps accents on Puerto Rico names (Bayamón zona urbana, Mayagüez zona urbana) and lists a name once no matter how many states have it, so Franklin is exactly as likely as Popponesset.

GenerateRandomFirstName picks male or female with equal probability first, then a name from that list, so any one male name is about 3.5 times likelier than any one female name. Use the gendered methods if you want uniform odds within a list.

The lists are embedded resources (RandomNameGeneratorLibrary/Resources.*.stripped, LF line endings, UTF-8). They were produced by the tools/CensusTools console project in this repository, which reads the Census files as Latin-1 and removes duplicates; it is not part of the package. The CensusListStripper and FileCompressor classes still in the library are the original one-off tools, marked obsolete, and will be removed in 3.0.

Building and releasing

dotnet test
dotnet pack RandomNameGeneratorLibrary -c Release -o artifacts

CI (.github/workflows/ci.yml) restores in locked mode, builds, checks formatting, runs the tests on Linux (net10.0) and Windows (net10.0 and net48, which exercises the netstandard2.0 build), collects coverage and packs on every push. To publish: add the entry to CHANGELOG.md, bump <Version> in RandomNameGeneratorLibrary.csproj, tag the commit v<version> and push the tag. The publish job checks that the tag matches the version, signs in to nuget.org with Trusted Publishing (GitHub OIDC, no stored API key; a NUGET_USER secret holding the nuget.org profile name lives in the nuget environment), pushes the package and creates a GitHub Release with the .nupkg and .snupkg attached. Package validation compares the public API against 2.0.1 at pack time, so an accidental breaking change fails the build.

License

MIT, see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on RandomNameGeneratorLibrary:

Package Downloads
shubcasinocommon

ShubCasino Common

Lombiq.Hosting.Tenants.Maintenance

Lombiq Hosting - Tenants Maintenance for Orchard Core: With the help of this module you can execute maintenance tasks on tenants. See the project website for detailed documentation.

IntechCommon

Intech Common Lib

SchoolTest

Package Description

DAP.Utils

Package Description

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on RandomNameGeneratorLibrary:

Repository Stars
microsoft/WhatTheHack
A collection of challenge based hack-a-thons including student guide, coach guide, lecture presentations, sample/instructional code and templates. Please visit the What The Hack website at: https://aka.ms/wth
JonPSmith/EfCore.TestSupport
Tools for helping in unit testing applications that use Entity Framework Core
Apress/pro-.net-memory
Source Code for 'Pro .NET Memory Management' by Konrad Kokosa
solliancenet/tech-immersion-data-ai
Version Downloads Last Updated
2.3.0 1,825 9/28/2026
2.3.0-beta.1 71 9/28/2026
2.2.0 213 9/27/2026
2.1.0 342 9/25/2026
2.0.1 132 9/25/2026
2.0.0 369 9/25/2026
1.2.2 3,888,429 10/17/2016
1.2.1 7,084 8/7/2016
1.2.0 3,486 8/7/2016
1.1.1 3,467 8/7/2016
1.1.0 8,390 8/7/2016
1.0.5.1 67,847 4/1/2014

2.1.0: place list fixed (49 Puerto Rico names had a broken character) and deduplicated so every place is equally likely; default generators no longer repeat each other on .NET Framework (#7); lists parsed lazily and thread-safely; new PersonNameGenerator(int seed) and PlaceNameGenerator(int seed); MaleFirstNames, FemaleFirstNames, LastNames and PlaceNames exposed as read-only lists; XML docs and nullable annotations; CensusListStripper and FileCompressor marked obsolete. Full history: https://github.com/m4bwav/DotNetRandomNameGenerator/blob/master/CHANGELOG.md