Comfort

Comfort

Three dials, four switches. Set once, remembered on this device only.

60%
10 or below holds everything still. 100 = full physics. Collisions still land within 50 ms.
0%
Starts at 0. Unlocks on your first tap, never on its own.
75%
Strength of the six inks. 0 is grey. Each chip's name is in its label.

Random number generator

Numbers, coin flips, dice and letters. One fair draw, straight from your browser crypto.

Ready

Press Draw for a number between 1 and 100.

Recent draws

  • Nothing yetYour last ten draws land here.

This list lives in this tab only. Reload the page and it is gone, because nothing here is saved.

How this random number generator picks a number

It asks your browser for fresh random bytes through crypto.getRandomValues, then throws away the few byte values that would make the low end of your range more likely, and only then maps what is left onto your numbers. That throwaway step is the whole thing. Without it every tool like this quietly favours small numbers.

The numbers, the coin, the dice and the letters all run through that one function. There is no second, sloppier path for the quick draws. Nothing is sent anywhere, because there is no server to send it to.

This is also why the page never touches Math.random. That one is a fast pseudorandom generator seeded by the browser at page load, it is explicitly documented as not suitable for anything that needs to be unguessable, and in V8 it produces its numbers in batches of 64 that can be worked backwards from a handful of outputs. For picking a film to watch it is fine. For a giveaway, a tournament seed or anything someone might argue about, it is not.

Why x % n is the wrong way to pick a random number

Because a byte holds 256 values and almost no range divides into 256 evenly, so the leftover values pile onto the bottom of your range. Take 1 to 7. Dividing 256 by 7 gives 36 with 4 left over, so results 1, 2, 3 and 4 each get 37 ways to happen while 5, 6 and 7 get 36. That is a 2.8 percent edge for the low four, forever, on every draw.

We measured it. Half a million draws of 1 to 7 through the sampler on this page land flat, chi square 6.39 against a critical value of 12.59, while the same half million through a plain byte % 7 land at chi square 98.8 with the low four running 2.84 percent high, which is almost exactly the 2.8 percent the arithmetic predicts.

The skew gets worse as the range grows. It stays small when the range is tiny next to the pool of bytes you draw from, and it gets ugly fast when the range approaches that pool. A lottery picker built on one sloppy modulo can be noticeably lopsided, and nobody checking by eye would ever see it.

Here is the fix, printed straight out of the function this page just ran:

function randomBelow(n) {
  let bits = 0;
  for (let m = n - 1; m > 0; m = Math.floor(m / 2)) bits++;
  const bytes = Math.ceil(bits / 8);
  const space = Math.pow(2, bytes * 8);
  const limit = space - (space % n);
  const buf = new Uint8Array(bytes);
  for (;;) {
    crypto.getRandomValues(buf);
    let x = 0;
    for (let i = 0; i < bytes; i++) x = x * 256 + buf[i];
    if (x < limit) return x % n;
  }
}

That block is printed from the live function, so it cannot drift away from what actually ran.

And here is the version to avoid. It is one line shorter and it is the most common defect in these tools:

// Do not do this. The low end of the range wins.
function biasedBelow(n) {
  const buf = new Uint8Array(1);
  crypto.getRandomValues(buf);
  return buf[0] % n;
}

Cutting the tail off costs almost nothing. For a range of 7 the sampler discards 1.56 percent of its bytes and redraws, so it averages 1.016 draws per number. The worst case is a range just over a power of two, where it throws away about half and averages two draws. Still instant.

Drawing numbers with no repeats

Switch off repeats and the draw uses a partial Fisher Yates shuffle, which guarantees every number comes out at most once and never slows down. The naive way is to draw and retry until you hit a number you have not seen, and that falls apart exactly when people need it: asking for 10 numbers from 1 to 10 means the last pick has a 1 in 10 chance of being new, so it retries about 10 times, and the whole draw costs roughly 30 attempts instead of 10.

Fisher Yates has no retries. It walks the list once, and at each step swaps the current slot with a random slot from the part it has not visited. Stop after the number of picks you wanted and you have a fair sample. Here it runs over a range that is never actually built in memory, so pulling 10 numbers out of 1 to 1000000 costs the same as pulling 10 out of 1 to 10.

Ask for more numbers than the range holds and the tool refuses and says so, because there is no honest answer. Nine unique numbers from 1 to 5 does not exist. Either widen the range, lower the count, or turn repeats on.

Is a coin flip really 50 to 50

Here, yes, exactly: heads is one of two equally likely outcomes with no leftover bytes to skew it, since 256 divides by 2 cleanly. Four hundred thousand test flips came out 199857 heads to 200143 tails, chi square 0.204 against a critical value of 3.841.

A real coin in a real hand is slightly different. Careful work on physical flips puts a caught coin at roughly 51 percent to land on the side it started on, because of how it precesses in the air, and a coin spun on a table can be far more lopsided than that because of its rim. So a digital flip is the fairer one, as long as the code behind it is honest.

The streaks are what trip people up. In 400000 test flips the longest run of one side was 20 in a row. Long runs are not a glitch, they are what randomness looks like, and a sequence with no long runs in it is the suspicious one. Hand written fake coin data is usually spotted by exactly that: people alternate too much.

Dice, advantage and disadvantage

Advantage rolls two d20 and keeps the higher result, disadvantage keeps the lower, and both show you both numbers so you can see what happened. That is the roll most people are actually looking for when they search for a dice roller, so it is built in rather than left for you to do twice and compare.

Worth knowing what it does to your odds. Advantage is worth about 3.3 to the average of a d20 roll, and it roughly doubles your chance of a natural 20, from 5 percent to 9.75 percent. The gain is biggest in the middle: if you need an 11 or better, advantage takes you from 50 percent to 75 percent. If you only need a 2, it barely helps.

The modifier is added once to the total, not once per die, which is how every tabletop rule set works it. So three d6 plus 2 gives a total from 5 to 20, and the individual dice are listed next to it so you can check the maths.

Random letters, vowels and alphabets

A random letter here is drawn flat, so every letter in the set you picked has the same chance, which is not how letters appear in real words. English text is about 12 percent E and about 0.07 percent Z, so a flat draw will hand you Q and X far more often than reading would. For a game that is the point, since a weighted draw would make it guessable.

Vowels only gives you five in English, A E I O U, and consonants only gives the other 21. Y is a consonant here. It behaves as a vowel in words like rhythm, but every letter game and spelling list treats it as a consonant, so that is the call.

Four other alphabets are in there. Spanish adds Ñ for 27. German adds Ä, Ö and Ü for 29, and leaves out ß because it has no capital form in normal use. Greek has 24. Russian has 33, including Ъ and Ь, which are signs rather than true consonants but sit with the consonants here because there is nowhere better to put them.

What a random number generator cannot do for you

It cannot make a draw you have already made fair, and it cannot settle an argument on its own. Anyone watching a result appear on your screen has only your word for it, which is why a public draw needs the result written down and shown to everyone before it runs, not after.

It is also not a password generator. Random digits in a range have far less variety per character than a real passphrase, and a password you can read off a number pad is a password worth guessing. Use something built for that job.

And the draws here are independent, every single time. Pressing Draw ten times is ten separate questions, so the same number showing up twice in a row means nothing went wrong. If you want ten different numbers, ask for ten in one draw with repeats switched off.

Related tools

Everything here runs in your browser. Nothing you type is sent anywhere or stored.