npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

randox

v2.0.0

Published

Random Number, Letter, Alphanumeric, and UUID generator. Lightweight and easy to use.

Readme

Randox

A lightweight and powerful JavaScript library for generating random values - numbers, letters, strings, UUIDs, colors, dates, passwords, and more.

npm version License: MIT

Features

  • 🎲 Random numbers with customizable length and ranges
  • 🔤 Random letters (lowercase or uppercase)
  • 🔢 Alphanumeric strings
  • 🆔 UUID v4 generation
  • 🎯 Random floats with precision control
  • 🎨 Random colors (hex, rgb, hsl)
  • 📅 Random dates within ranges
  • 🔐 Secure random IDs and passwords
  • ✨ Random choices from arrays
  • 🌐 Works everywhere: Node.js, browsers, and CDN
  • 🪶 Zero dependencies
  • ⚡ Simple and intuitive API
  • 📦 CommonJS and ES modules support

Installation

npm install randox

Usage

Node.js (CommonJS)

const { 
  number, 
  letter, 
  alphanum, 
  v4: uuid,
  range,
  float,
  hex,
  bool,
  choice,
  string,
  password,
  date,
  color,
  id,
  secure
} = require('randox');

console.log(number(6));           // '482916'
console.log(letter(5, true));     // 'HBXWN'
console.log(uuid());              // '550e8400-e29b-41d4-a716-446655440000'
console.log(password(12));        // 'X9k#mP2$nQ5!'

Node.js (ES Modules)

import { 
  number, 
  letter, 
  alphanum, 
  v4 as uuid,
  range,
  float,
  hex,
  bool,
  choice,
  string,
  password,
  date,
  color,
  id,
  secure
} from 'randox';

console.log(range(1, 100));       // 42
console.log(float(0, 1, 2));      // 0.73
console.log(color('hex'));        // '#a3c2f0'

Browser (CDN)

<script src="https://unpkg.com/randox/dist/randox.umd.js"></script>
<script>
  console.log(Randox.number(4));        // '8261'
  console.log(Randox.letter(5));        // 'mxkpt'
  console.log(Randox.alphanum(8));      // 'a4x9m2p7'
  console.log(Randox.v4());             // 'c9bf9e57-1685-4c89-bafb-ff5af830be8a'
  console.log(Randox.range(1, 10));     // 7
  console.log(Randox.float(0, 100, 1)); // 45.3
  console.log(Randox.hex(6));           // 'a3f8c2'
  console.log(Randox.bool());           // true
  console.log(Randox.choice(['a', 'b', 'c'])); // 'b'
  console.log(Randox.string(10));       // 'aBcDeFgHiJ'
  console.log(Randox.password(16));     // 'X9k#mP2$nQ5!wR7@'
  console.log(Randox.date('2024-01-01', '2024-12-31')); // Date object
  console.log(Randox.color('rgb'));     // 'rgb(123, 45, 200)'
  console.log(Randox.id('user'));       // 'user_a4x9m2p7'
  console.log(Randox.secure(32));       // 'a3f8c2...' (64 char hex)
</script>

API Reference

number(length)

Generates a random number string with specified length.

Parameters:

  • length (optional): Number of digits. Default: 1

Returns: String of random digits

number();    // '5'
number(3);   // '472'
number(10);  // '8392847561'

letter(length, upper)

Generates random letters.

Parameters:

  • length (optional): Number of letters. Default: 1
  • upper (optional): Generate uppercase if true. Default: false

Returns: String of random letters

letter();        // 'p'
letter(5);       // 'mxkpt'
letter(5, true); // 'WQRNZ'

alphanum(length)

Generates random alphanumeric string.

Parameters:

  • length (optional): Number of characters. Default: 1

Returns: String of random alphanumeric characters

alphanum();   // 'k'
alphanum(8);  // 'a4x9m2p7'
alphanum(16); // 'f8k3m9x2p7a1n5q4'

v4()

Generates a standard UUID v4.

Returns: UUID v4 string

v4(); // '550e8400-e29b-41d4-a716-446655440000'
v4(); // 'c9bf9e57-1685-4c89-bafb-ff5af830be8a'

range(min, max)

Generates a random integer within a range (inclusive).

Parameters:

  • min: Minimum value
  • max: Maximum value

Returns: Random integer between min and max

range(1, 10);    // 7
range(0, 100);   // 42
range(-50, 50);  // -23

float(min, max, precision)

Generates a random floating-point number.

Parameters:

  • min: Minimum value
  • max: Maximum value
  • precision (optional): Number of decimal places. Default: 2

Returns: Random float between min and max

float(0, 1);        // 0.73
float(0, 100, 1);   // 45.3
float(0, 1, 4);     // 0.7284

hex(length)

Generates a random hexadecimal string.

Parameters:

  • length (optional): Number of hex characters. Default: 1

Returns: Random hex string

hex();     // 'a'
hex(6);    // 'a3f8c2'
hex(8);    // '1f4d9b2e'

bool()

Generates a random boolean value.

Returns: true or false

bool(); // true
bool(); // false

choice(array)

Selects a random element from an array.

Parameters:

  • array: Array to choose from

Returns: Random element from the array

choice(['apple', 'banana', 'orange']); // 'banana'
choice([1, 2, 3, 4, 5]);              // 3
choice(['red', 'green', 'blue']);     // 'green'

string(length, options)

Generates a random string with mixed characters.

Parameters:

  • length (optional): String length. Default: 10
  • options (optional): Character set options
    • lowercase: Include lowercase letters. Default: true
    • uppercase: Include uppercase letters. Default: true
    • numbers: Include numbers. Default: true
    • symbols: Include symbols. Default: false

Returns: Random string

string(10);                              // 'aBc3DeF7gH'
string(8, { uppercase: false });         // 'abc123de'
string(12, { symbols: true });           // 'aB3#dE7$fG9!'

password(length, options)

Generates a strong random password.

Parameters:

  • length (optional): Password length. Default: 16
  • options (optional): Character set options
    • lowercase: Include lowercase. Default: true
    • uppercase: Include uppercase. Default: true
    • numbers: Include numbers. Default: true
    • symbols: Include symbols. Default: true

Returns: Secure random password

password();                                // 'X9k#mP2$nQ5!wR7@'
password(12);                              // 'aB3#dE7$fG9!'
password(20, { symbols: false });          // 'aBcDeF123GhIjK456'

date(start, end)

Generates a random date within a range.

Parameters:

  • start (optional): Start date (Date object or ISO string). Default: '1970-01-01'
  • end (optional): End date (Date object or ISO string). Default: current date

Returns: Random Date object

date();                                    // Random date between 1970 and now
date('2024-01-01', '2024-12-31');         // Random date in 2024
date(new Date('2023-01-01'), new Date()); // Random date since 2023

color(format)

Generates a random color.

Parameters:

  • format (optional): Color format - 'hex', 'rgb', or 'hsl'. Default: 'hex'

Returns: Random color string

color();          // '#a3c2f0'
color('hex');     // '#ff5733'
color('rgb');     // 'rgb(123, 45, 200)'
color('hsl');     // 'hsl(240, 70%, 50%)'

id(prefix)

Generates a unique ID with optional prefix.

Parameters:

  • prefix (optional): String to prefix the ID with

Returns: Unique ID string

id();           // 'a4x9m2p7n5q3'
id('user');     // 'user_k8j3m9x2'
id('order');    // 'order_p7a1n5q4'

secure(bytes)

Generates a cryptographically secure random hex string.

Parameters:

  • bytes (optional): Number of random bytes to generate. Default: 16

Returns: Secure hex string (length = bytes × 2)

secure();     // 'a3f8c2d4e5b6f7a8c9d0e1f2a3b4c5d6' (32 chars)
secure(8);    // 'a3f8c2d4e5b6f7a8' (16 chars)
secure(32);   // '...' (64 chars)

Use Cases

  • 🔐 Generating secure passwords and tokens
  • 🎮 Game development (dice rolls, random events)
  • 🧪 Testing and mock data generation
  • 🆔 Creating unique identifiers and session IDs
  • 📧 Verification codes and OTPs
  • 🎨 Random UI color schemes
  • 📁 Unique filename generation
  • 🎯 A/B testing and randomization
  • 📊 Synthetic data creation
  • 🔑 API key generation

Why Randox?

  • Zero Dependencies: No bloat, pure functionality
  • Tiny Footprint: Minimal bundle size impact
  • Universal: Works in Node.js, browsers, and via CDN
  • Simple API: Intuitive names and sensible defaults
  • Comprehensive: Everything you need for random generation
  • Secure Options: Cryptographically secure functions included
  • Well-Tested: Thoroughly tested for reliability
  • MIT Licensed: Free for any project

Requirements

  • Node.js 18.x or higher
  • Modern browsers with ES6+ support

Browser Compatibility

Randox works in all modern browsers:

  • Chrome/Edge 60+
  • Firefox 55+
  • Safari 12+
  • Opera 47+

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © Anurag Anand

Support

If you encounter issues or have questions, please file an issue on the GitHub repository.


Made with ❤️ for developers by Anurag