Generates a random alphanumeric string containing digits and lowercase letters.

Creates a string of specified length using characters from 0-9 and a-z. Each position is independently randomly selected from the combined character set. Ideal for generating random IDs, tokens, passwords, or unique identifiers that need both numeric and alphabetic characters.

  RandomGenerator.alphaNumeric(8);  // "a1b2c3d4"
RandomGenerator.alphaNumeric(12); // "x9y8z7w6v5u4"

// Generate random API keys
const apiKey = RandomGenerator.alphaNumeric(32);

// Create session tokens
const sessionId = `sess_${RandomGenerator.alphaNumeric(16)}`;

// Generate test database IDs
const testId = RandomGenerator.alphaNumeric(10);
  • Parameters

    • length: number

      The desired length of the generated alphanumeric string

    Returns string

    A string containing digits and lowercase letters of the specified length