Generates a random name-like string with realistic length variation.

Creates a name by generating a paragraph with 2-3 words (randomly chosen). The resulting string resembles typical human names in structure and length. Each word is between 3-7 characters by default, creating realistic-looking names.

  RandomGenerator.name();    // "john doe"
RandomGenerator.name(1); // "alice"
RandomGenerator.name(3); // "jane mary smith"

// Generate test user names
const users = Array.from({ length: 10 }, () => ({
id: RandomGenerator.alphaNumeric(8),
name: RandomGenerator.name(),
email: `${RandomGenerator.name(1)}@test.com`
}));

// Create random author names for blog posts
const authorName = RandomGenerator.name();
  • Parameters

    • length: number = ...

      Number of words in the name (default: random between 2-3)

    Returns string

    A space-separated string resembling a human name