Full Name Generator - Generate Random Names
Generate random names effortlessly using various data sources of popular first names and surnames from multiple countries.
If you find this package helpful, please consider ⭐ starring it on GitHub.
$ npm install full-name-generator --saveimport { firstName, lastName, fullName, Gender } from 'full-name-generator';
// Generate Full Names
const maleFullName = fullName('US', Gender.Male);
const femaleFullName = fullName('US', Gender.Female);
// Generate First Names
const maleFirstName = firstName('US', Gender.Male);
const femaleFirstName = firstName('US', Gender.Female);
// Generate Surnames
const turkishSurname = lastName('TR');
const czechFemaleSurname = lastName('CZ', Gender.Female);
// Generate Multiple Names
const twoAmericanMaleFirstNames = firstName('US', Gender.Male, 2);
const twoAmericanLastNames = lastName('US', undefined, 2);
const twoAmericanNamesThreeSurnamesFemaleFullName = fullName('US', Gender.Female, 2, 3);
// Custom separator
const hyphenatedName = fullName('US', Gender.Male, 1, 1, '-');Note: While numeric values (0 for Male, 1 for Female) still work for backward compatibility, using the
Genderenum is recommended for better code readability.
- 🇦🇷 Argentina (AR)
- 🇦🇹 Austria (AT)
- 🇧🇪 Belgium (BE)
- 🇧🇷 Brazil (BR)
- 🇨🇳 China (CN)
- 🇨🇿 Czechia (CZ)
- 🇩🇰 Denmark (DK)
- 🇫🇮 Finland (FI)
- 🇫🇷 France (FR)
- 🇩🇪 Germany (DE)
- 🇬🇷 Greece (GR)
- 🇮🇳 India (IN)
- 🇮🇩 Indonesia (ID)
- 🇮🇱 Israel (IL)
- 🇮🇹 Italy (IT)
- 🇯🇵 Japan (JP)
- 🇲🇽 Mexico (MX)
- 🇳🇱 Netherlands (NL)
- 🇳🇴 Norway (NO)
- 🇵🇱 Poland (PL)
- 🇵🇹 Portugal (PT)
- 🇷🇺 Russia (RU)
- 🇸🇦 Saudi Arabia (SA)
- 🇰🇷 South Korea (KR)
- 🇪🇸 Spain (ES)
- 🇸🇪 Sweden (SE)
- 🇹🇼 Taiwan (TW)
- 🇹🇭 Thailand (TH)
- 🇹🇷 Türkiye (TR)
- 🇬🇧 United Kingdom (GB)
- 🇺🇸 United States (US)
- 🇻🇳 Vietnam (VN)
enum Gender {
Male = 0,
Female = 1
}Generates a full name based on the provided parameters.
fullName(isoCode: string, gender: Gender, firstN?: number, lastN?: number, space?: string): stringParameters:
- isoCode: The ISO code for the country (e.g., 'BR', 'CZ', 'US'). Case-insensitive.
- gender: Gender category for the name. Use
Gender.MaleorGender.Female(or numeric values 0/1). - firstN: Number of first names to be generated (default:
1). - lastN: Number of surnames to be generated (default:
1). - space: Separator between the first names and surnames (default:
' ').
Returns: A randomly generated full name as a string.
Generates one or more first names based on the provided country code and gender.
firstName(isoCode: string, gender: Gender, n?: number): stringParameters:
- isoCode: The ISO code for the country (e.g., 'BR', 'CZ', 'US'). Case-insensitive.
- gender: Gender category for the name. Use
Gender.MaleorGender.Female(or numeric values 0/1). - n: Number of first names to generate (default:
1).
Returns: A randomly generated first name (or multiple names separated by spaces).
Generates one or more surnames. For some countries like the Czechia or Poland, gender is considered.
lastName(isoCode: string, gender?: Gender, n?: number): stringParameters:
- isoCode: The ISO code for the country (e.g., 'BR', 'CZ', 'US'). Case-insensitive.
- gender: (Optional) Gender category for the surname. Required for countries like Czechia and Poland.
Use
Gender.MaleorGender.Female(or numeric values 0/1). - n: Number of surnames to generate (default:
1).
Returns: A randomly generated surname (or multiple surnames separated by spaces).
The MIT License (MIT). Please see License File for more information.
To reference this project, use the code snippet below:
<a href="https://fullnamegenerator.com">Full Name Generator</a>