Skip to content

randName

Generates person names and returns count of them as strings, written in the script you asked for. With output: 'detail' it returns the native and romanized form of each name instead, together with the language and gender behind it.

javascript
import { randName } from 'randino';

randName();
// ['Emma Clover']
dart
import 'package:randino/randino.dart';

randName();
// ['Emma Clover']
python
from randino import rand_name

rand_name()
# ['Emma Clover']

Options

Every option is optional, and the defaults are what the empty call above uses.

OptionTypeDefaultDescription
languageNameLanguageOptionNameLanguage?NameLanguageOption'all'null"all"Language of the generated names. 'all'null"all" mixes every supported language, picking one per name.
genderNameGenderOptionNameGender?NameGenderOption'all'null"all"Which pools the given name is drawn from. Left out, a gender is picked per name.
countnumberintint1How many names to return. Clamped to 010000.
realismRandRealism<Lang js="'real'" dart="RandRealism.real" py="\"real\"" />real draws names people actually carry, invented builds new ones, and mixed decides per part.
minLengthminLengthmin_lengthnumberint?int | NonelanguageMinimum length of the native form, in characters.
maxLengthmaxLengthmax_lengthnumberint?int | NonelanguageMaximum length of the native form, in characters.
includeSurnameincludeSurnameinclude_surnamebooleanboolbooltruetrueTrueInclude the family name.
includeMiddleNameincludeMiddleNameinclude_middle_namebooleanboolboolfalsefalseFalseInclude a middle name. Ignored for languages that have none.
scriptNameScript'native'NameScript.native"native"The script the returned strings are written in.
startsWithstartsWithstarts_withstringString?strnull""Keep only names whose native form starts with this character. Only the first character is used, and the match is case-insensitive.
uniquebooleanboolboolfalsefalseFalseNever return the same name twice. May return fewer than count once the pools run out of combinations.
outputRandOutputRandOutput'value'"value"Strings, or a NameDetail per name. Dart has no such parameter — see the detail output.
random() => numberRandom?Callable[[], float] | NonenullNoneWhere the randomness comes from — see Choosing the source. Defaults to the platform's ordinary generator.
minLengthminLengthmin_length and maxLengthmaxLengthmax_length default to the language's own range, which nameLengthRange reports. That fallback is resolved per language, so a mixed draw does not stretch a Korean name to fill a Spanish name's range.

The detail output

output: 'detail' returns each name in both scripts at once, with the language and gender behind it, instead of a string. Useful for showing a name next to its English pronunciation, and necessary when the draw is mixed and you need to know what each name is. script has nothing left to choose there, so it is ignored.

Dart spells this as a second function, randNameDetails, because it has no way to make one function's return type depend on an argument. It takes the same parameters as randName except script.

javascript
import { randName } from 'randino';

randName({ language: 'ko', output: 'detail' });
// [{ native: '여미주', roman: 'Yeo Miju', language: 'ko', gender: 'female' }]
dart
import 'package:randino/randino.dart';

randNameDetails(language: NameLanguage.ko);
// [NameDetail(여미주, Yeo Miju, ko, female)]
python
from randino import rand_name

rand_name(language="ko", output="detail")
# [NameDetail(native='여미주', roman='Yeo Miju', language='ko', gender='female')]

Each entry is a NameDetail:

Each entry is a NameDetail:

Each entry is a NameDetail, a frozen dataclass:

FieldTypeDescription
nativestringStringstrThe name in its own script.
romanstringStringstrThe English pronunciation of native. Identical to it for English.
languageNameLanguageThe language this name was generated in — the reason to reach for this function when the draw is mixed.
genderNameGenderThe pools the given name was drawn from.

Examples

One language at a time

javascript
randName({ language: 'ko', count: 3 });
// ['김태윤', '원동혁', '조진우']

randName({ language: 'ja', count: 3 });
// ['山崎愛菜', '加藤楓乃', '吉田直人']

randName({ language: 'ru', count: 2 });
// ['Дмитрий Соколов', 'Полина Морозова']
dart
randName(language: NameLanguage.ko, count: 3);
// ['김태윤', '원동혁', '조진우']

randName(language: NameLanguage.ja, count: 3);
// ['山崎愛菜', '加藤楓乃', '吉田直人']

randName(language: NameLanguage.ru, count: 2);
// ['Дмитрий Соколов', 'Полина Морозова']
python
rand_name(language="ko", count=3)
# ['김태윤', '원동혁', '조진우']

rand_name(language="ja", count=3)
# ['山崎愛菜', '加藤楓乃', '吉田直人']

rand_name(language="ru", count=2)
# ['Дмитрий Соколов', 'Полина Морозова']

Leave the language out and every name comes from one of the nine, picked per name:

javascript
randName({ count: 5 });
// ['Nuria Ramírez', '조동민', 'Stella Reeves', 'Anna Mariani', 'Lê Phương']
dart
randName(count: 5);
// ['Nuria Ramírez', '조동민', 'Stella Reeves', 'Anna Mariani', 'Lê Phương']
python
rand_name(count=5)
# ['Nuria Ramírez', '조동민', 'Stella Reeves', 'Anna Mariani', 'Lê Phương']

The parts of a name

javascript
randName({ language: 'en', count: 3, includeSurname: false });
// ['Rachel', 'Eliza', 'Tessa']

randName({ language: 'en', count: 3, includeMiddleName: true });
// ['Danielle Sylvia Owens', 'Gloria Harriet Norton', 'Peyton Beatrix Owens']
dart
randName(language: NameLanguage.en, count: 3, includeSurname: false);
// ['Rachel', 'Eliza', 'Tessa']

randName(language: NameLanguage.en, count: 3, includeMiddleName: true);
// ['Danielle Sylvia Owens', 'Gloria Harriet Norton', 'Peyton Beatrix Owens']
python
rand_name(language="en", count=3, include_surname=False)
# ['Rachel', 'Eliza', 'Tessa']

rand_name(language="en", count=3, include_middle_name=True)
# ['Danielle Sylvia Owens', 'Gloria Harriet Norton', 'Peyton Beatrix Owens']

Korean, Japanese and Chinese have no middle part, so includeMiddleNameincludeMiddleNameinclude_middle_name is ignored for them rather than inventing one. nameSupportsMiddleName answers that directly.

Romanized output

javascript
randName({ language: 'ko', count: 3, script: 'roman' });
// ['Kim Minjun', 'Won Donghyeok', 'Jo Jinu']

randName({ language: 'ja', count: 3, script: 'roman' });
// ['Yamazaki Aina', 'Kato Kaeno', 'Yoshida Naoyato']
dart
randName(language: NameLanguage.ko, count: 3, script: NameScript.roman);
// ['Kim Minjun', 'Won Donghyeok', 'Jo Jinu']

randName(language: NameLanguage.ja, count: 3, script: NameScript.roman);
// ['Yamazaki Aina', 'Kato Kaeno', 'Yoshida Naoyato']
python
rand_name(language="ko", count=3, script="roman")
# ['Kim Minjun', 'Won Donghyeok', 'Jo Jinu']

rand_name(language="ja", count=3, script="roman")
# ['Yamazaki Aina', 'Kato Kaeno', 'Yoshida Naoyato']

English is the one language where this changes nothing, because the names are already in the Latin alphabet. nameSupportsRoman reports that.

A starting character

javascript
randName({ language: 'en', count: 3, startsWith: 'k' });
// ['Kayla Morgan', 'Keith Doyle', 'Kimberly Vaughn']
dart
randName(language: NameLanguage.en, count: 3, startsWith: 'k');
// ['Kayla Morgan', 'Keith Doyle', 'Kimberly Vaughn']
python
rand_name(language="en", count=3, starts_with="k")
# ['Kayla Morgan', 'Keith Doyle', 'Kimberly Vaughn']

A character no real name starts with still returns names rather than nothing: Latin and Cyrillic scripts invent one (QQivu Railooth), and CJK scripts use the character as a name part of its own.

Length

javascript
randName({ language: 'en', count: 2, minLength: 20, maxLength: 25 });
// ['Josephine Adelaide Sinclair', 'Christina Genevieve Whitaker']
dart
randName(language: NameLanguage.en, count: 2, minLength: 20, maxLength: 25);
// ['Josephine Adelaide Sinclair', 'Christina Genevieve Whitaker']
python
rand_name(language="en", count=2, min_length=20, max_length=25)
# ['Josephine Adelaide Sinclair', 'Christina Genevieve Whitaker']

The structure you asked for always wins. A range too narrow for the requested parts is answered with the closest name the generator can build, never by dropping the surname or middle name. See how the options behave.

A name next to its pronunciation

javascript
for (const { native, roman } of randName({ language: 'ja', count: 3, output: 'detail' })) {
	console.log(`${native} (${roman})`);
}
// 山崎愛菜 (Yamazaki Aina)
// 加藤楓乃 (Kato Kaeno)
// 吉田直人 (Yoshida Naoto)
dart
for (final detail in randNameDetails(language: NameLanguage.ja, count: 3)) {
  print('${detail.native} (${detail.roman})');
}
// 山崎愛菜 (Yamazaki Aina)
// 加藤楓乃 (Kato Kaeno)
// 吉田直人 (Yoshida Naoto)
python
for detail in rand_name(language="ja", count=3, output="detail"):
    print(f"{detail.native} ({detail.roman})")
# 山崎愛菜 (Yamazaki Aina)
# 加藤楓乃 (Kato Kaeno)
# 吉田直人 (Yoshida Naoto)

Knowing what a mixed draw produced

javascript
randName({ count: 3, output: 'detail' });
// [
//   { native: '조동민', roman: 'Jo Dongmin', language: 'ko', gender: 'male' },
//   { native: 'Anna Mariani', roman: 'Anna Mariani', language: 'it', gender: 'female' },
//   { native: 'Иванов Иван', roman: 'Ivanov Ivan', language: 'ru', gender: 'male' }
// ]
dart
randNameDetails(count: 3);
// [
//   NameDetail(조동민, Jo Dongmin, ko, male),
//   NameDetail(Anna Mariani, Anna Mariani, it, female),
//   NameDetail(Иванов Иван, Ivanov Ivan, ru, male),
// ]
python
rand_name(count=3, output="detail")
# [
#     NameDetail(native='조동민', roman='Jo Dongmin', language='ko', gender='male'),
#     NameDetail(native='Anna Mariani', roman='Anna Mariani', language='it', gender='female'),
#     NameDetail(native='Иванов Иван', roman='Ivanov Ivan', language='ru', gender='male'),
# ]

Gender, where it is observable

Most languages do not show which pool a given name came from. Russian does, because its patronymic and its surname both inflect, which makes the choice verifiable there:

javascript
randName({ language: 'ru', gender: 'female', includeMiddleName: true, count: 2, output: 'detail' });
// [
//   { native: 'Людмила Николаевна Богданова', roman: 'Lyudmila Nikolaevna Bogdanova', … },
//   { native: 'Марина Максимовна Богданова', roman: 'Marina Maksimovna Bogdanova', … }
// ]
dart
randNameDetails(
  language: NameLanguage.ru,
  gender: NameGender.female,
  includeMiddleName: true,
  count: 2,
);
// [
//   NameDetail(Людмила Николаевна Богданова, Lyudmila Nikolaevna Bogdanova, ru, female),
//   NameDetail(Марина Максимовна Богданова, Marina Maksimovna Bogdanova, ru, female),
// ]
python
rand_name(language="ru", gender="female", include_middle_name=True, count=2, output="detail")
# [
#     NameDetail(native='Людмила Николаевна Богданова', roman='Lyudmila Nikolaevna Bogdanova', …),
#     NameDetail(native='Марина Максимовна Богданова', roman='Marina Maksimovna Bogdanova', …),
# ]

See also

Released under the MIT License