Skip to content

ozdemirburak/full-name-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Full Name Generator - Generate Random Names

npm-version npm-downloads license

Generate random names using authentic data sourced from government statistical offices across 25 countries, including popular first names and surnames from official national datasets.

IMPORTANT: This library's code is MIT licensed, but the name data requires attribution under various government open data licenses. See License & Attribution for details.

Installation

$ npm install full-name-generator --save

Usage

By default, this package includes a lite version with 15 names/surnames per gender per country for smaller bundle sizes. If you need access to the complete dataset, see Full Version below.

import { 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, '-');

Full Version

If you need access to the complete dataset with all names and surnames:

import { firstName, lastName, fullName, Gender } from 'full-name-generator/full';

const name = fullName('US', Gender.Male);

Countries

  • ๐Ÿ‡ฆ๐Ÿ‡ท Argentina (AR)
  • ๐Ÿ‡ง๐Ÿ‡ช Belgium (BE)
  • ๐Ÿ‡ง๐Ÿ‡ท Brazil (BR)
  • ๐Ÿ‡จ๐Ÿ‡ฟ Czechia (CZ)
  • ๐Ÿ‡ฉ๐Ÿ‡ฐ Denmark (DK)
  • ๐Ÿ‡ซ๐Ÿ‡ฎ Finland (FI)
  • ๐Ÿ‡ซ๐Ÿ‡ท France (FR)
  • ๐Ÿ‡ฎ๐Ÿ‡ธ Iceland (IS)
  • ๐Ÿ‡ฎ๐Ÿ‡ช Ireland (IE)
  • ๐Ÿ‡ฎ๐Ÿ‡ฑ Israel (IL)
  • ๐Ÿ‡ฎ๐Ÿ‡น Italy (IT)
  • ๐Ÿ‡ฑ๐Ÿ‡ป Latvia (LV)
  • ๐Ÿ‡ฐ๐Ÿ‡ฟ Kazakhstan (KZ)
  • ๐Ÿ‡ฒ๐Ÿ‡ฝ Mexico (MX)
  • ๐Ÿ‡ณ๐Ÿ‡ฟ New Zealand (NZ)
  • ๐Ÿ‡ณ๐Ÿ‡ด Norway (NO)
  • ๐Ÿ‡ต๐Ÿ‡ฑ Poland (PL)
  • ๐Ÿ‡ธ๐Ÿ‡ฎ Slovenia (SI)
  • ๐Ÿ‡ฐ๐Ÿ‡ท South Korea (KR)
  • ๐Ÿ‡ช๐Ÿ‡ธ Spain (ES)
  • ๐Ÿ‡ธ๐Ÿ‡ช Sweden (SE)
  • ๐Ÿ‡น๐Ÿ‡ผ Taiwan (TW)
  • ๐Ÿ‡น๐Ÿ‡ท Tรผrkiye (TR)
  • ๐Ÿ‡ฌ๐Ÿ‡ง United Kingdom (GB)
  • ๐Ÿ‡บ๐Ÿ‡ธ United States (US)

API Reference

Gender Enum

enum Gender {
  Male = 0,
  Female = 1
}

fullName()

Generates a full name based on the provided parameters.

fullName(isoCode: string, gender: Gender, firstN?: number, lastN?: number, space?: string): string

Parameters:

  • isoCode: The ISO code for the country (e.g., 'BR', 'CZ', 'US'). Case-insensitive.
  • gender: Gender category for the name. Use Gender.Male or Gender.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.

firstName()

Generates one or more first names based on the provided country code and gender.

firstName(isoCode: string, gender: Gender, n?: number): string

Parameters:

  • isoCode: The ISO code for the country (e.g., 'BR', 'CZ', 'US'). Case-insensitive.
  • gender: Gender category for the name. Use Gender.Male or Gender.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).

lastName()

Generates one or more surnames. For some countries like Czechia, Iceland, Latvia, and Poland, gender is considered.

lastName(isoCode: string, gender?: Gender, n?: number): string

Parameters:

  • 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, Iceland, Latvia, and Poland. Use Gender.Male or Gender.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).

License

This library has a dual licensing structure:

1. Code License

The source code implementation (TypeScript/JavaScript functions, logic, and types) is licensed under the MIT License.

2. Data License

The name and surname datasets embedded in this package are sourced from government statistical offices under various open data licenses.

IMPORTANT: When you use this package, you are using a combined work and must comply with BOTH the code license (MIT) and the applicable data licenses.

REQUIREMENT: Most countries require you to provide attribution to the original data sources. Failure to comply may violate the data licenses.

Required Attribution

Below are the data sources and their respective licenses:

If you find this library helpful, linking back to us is also appreciated but not required:


For specific dataset URLs, refer to the header comments in src/names/{country}.ts and src/surnames/{country}.ts files in the names and surnames folders.

About

Generate random names using data from popular names and surnames of various countries.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 11