Try it instantly — Use our free Random Number Generator to pick a single number or run a full raffle draw with no duplicates.

What is a random number generator?

A random number generator (RNG) produces numbers with no predictable pattern. There are two main types:

For everyday use — giveaways, games, picking a winner, statistical simulations — a high-quality PRNG like the browser's Math.random() is more than sufficient. It passes all standard randomness tests including Diehard and TestU01.

How to run a fair raffle — step by step

  1. Assign a number to each participant. If you have 50 people, your range is 1–50.
  2. Open the Random Number Generator. Select Raffle Draw mode.
  3. Set Min to 1 and Max to 50 (or whatever your participant count is).
  4. Set "How many" to the number of winners you need — e.g., 3 for first, second, and third prizes.
  5. Enable "No duplicates." This ensures each participant can only win once.
  6. Click Run Raffle Draw. Each ball animates independently and lands on a unique number.
  7. Copy and record the results. The History panel keeps the last 8 draws for reference.

The Fisher-Yates shuffle — how no-duplicate draws work

The Fisher-Yates shuffle (also called the Knuth shuffle) is the standard algorithm for producing uniformly random permutations:

  1. Create an array with every number in the range: [1, 2, 3, …, N]
  2. For each position from the last to the first, swap it with a randomly chosen earlier position.
  3. Take the first K elements of the shuffled array as your draw results.

Every permutation is equally likely, which makes it mathematically equivalent to drawing numbers from a physical urn — no bias, no duplicates.

Generate random numbers in code

JavaScript

// Random integer between min and max (inclusive)
function randInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

randInt(1, 100); // e.g. 42

// Cryptographically secure (for passwords/tokens)
const array = new Uint32Array(1);
crypto.getRandomValues(array);
const secure = array[0] % 100 + 1; // 1–100

Python

import random

# Single random integer
random.randint(1, 100)  # e.g. 73

# Raffle: 5 unique numbers from 1–50
winners = random.sample(range(1, 51), 5)

# Cryptographically secure
import secrets
secrets.randbelow(100) + 1  # 1–100

Excel / Google Sheets

=RANDBETWEEN(1, 100)          ' Random integer 1–100
=RANK(RAND(), RAND()...)      ' Shuffle rows (workaround)

' Note: RANDBETWEEN recalculates on every change.
' Paste as values (Ctrl+Shift+V) to freeze results.

PHP

<?php
// Standard (Mersenne Twister)
$n = rand(1, 100);

// Cryptographically secure
$n = random_int(1, 100);
?>

Ruby

# Random integer 1–100
rand(1..100)

# Secure random
require 'securerandom'
SecureRandom.random_number(100) + 1

Tips for fair and transparent draws

Frequently asked questions

Is Math.random() good enough for a raffle?

Yes. Browser PRNGs use algorithms like xorshift128+ that produce billions of distinct values with no detectable bias. For a raffle with hundreds or thousands of participants, the probability of any unfair outcome is negligible.

What's the difference between Math.random() and crypto.getRandomValues()?

Math.random() is fast and suitable for games, simulations, and draws. crypto.getRandomValues() uses the OS entropy pool and is cryptographically secure — required for passwords, tokens, and session IDs, but unnecessary overhead for simple number picking.

How do I generate a random number between 1 and 100?

Online: open our tool, set Min to 1 and Max to 100, click Generate. In code: Math.floor(Math.random() * 100) + 1 in JavaScript, or random.randint(1, 100) in Python.

Can two people get the same number in raffle mode?

Not when "no duplicates" is enabled. With duplicates allowed, the same number can appear more than once — useful when you're simulating dice rolls or sampling with replacement.

Conclusion

A good random number generator covers everything from picking tonight's dinner to running a fully auditable prize draw. For everyday use, browser-based PRNGs are statistically fair and more than sufficient. When you need cryptographic guarantees, reach for crypto.getRandomValues() or your language's secrets module.

Ready to run your draw? Open the Random Number Generator →

Related tools