Skip to content
xmoo.app

Tool · Fun & random

Random Number Generator

A random number between two values, a handful of dice, a coin flip or a list in a new order – all with the same fair randomness from your browser.

What should chance do?

Whole numbers, negative too, up to 10¹⁵; at most 1,000 at a time.

What the generator does

Prefer a wheel and a bit of suspense? Try the wheel spinner. To pick who does the washing-up or to split a group into teams, use the random name picker.

Where the randomness comes from

A computer is deterministic: the same input gives the same result. For randomness it needs a source it cannot work out itself. Operating systems collect unpredictable events for this – the exact timing of key presses, network packets and disk access, plus hardware random number generators in the processor – and mix them into a pool from which a cryptographic random number generator produces numbers.

A web page reaches that pool through the Web Crypto API with crypto.getRandomValues. This generator uses it for every number, every die and every coin flip. The better-known Math.random is meant for animations and games: it is fast, but the standard does not require it to be unpredictable.

Fair means: no modulo bias

The source delivers whole numbers from 0 to 2³² − 1, so 4,294,967,296 different values. A die only needs six. The usual trick, “remainder after dividing by 6, plus 1”, has a catch: 4,294,967,296 is not divisible by 6. There is a remainder of 4 – so the faces 1 to 4 would each come up once more often than 5 and 6.

With 2³² values the effect is tiny. It becomes clear if you work it through with a single byte, which only has 256 values (0 to 255):

  1. 256 ÷ 6 = 42 remainder 4. The largest multiple of 6 below 256 is 42 · 6 = 252.
  2. Without rejection the values 252 to 255 land on faces 1 to 4. Those faces then get 43 of the 256 values each (16.8 %), while 5 and 6 get only 42 (16.4 %).
  3. With rejection any value from 252 upwards is thrown away and drawn again. What remains is 0 to 251, and each face gets exactly 42 of 252 values – precisely 1/6.
One byte: values 0 to 255, a die with 6 faces 1 2 3 4 5 6 252–255 0 to 251: 42 · 6 = 252 values, 42 per face Remainder: 4 values without rejection: 1–4 each 43/256 ≈ 16.8%, 5–6 each 42/256 ≈ 16.4% with rejection: redraw 252–255, every face 42/252 = 1/6 With 2³² = 4,294,967,296 values the remainder is 4 as well.
Why values are thrown away: otherwise the remainder of the division favours the low faces. Values from the one-byte example. Own illustration.

“Without repeats” works the same way: each new number is drawn fairly; if it is already there, it is thrown away and drawn again – like a ball that does not go back into the drum. To shuffle a list the tool uses the Fisher–Yates method in Durstenfeld’s version: working from the back to the front, each entry swaps with a fairly chosen entry before it (or with itself). Every possible order is equally likely.

Flip a coin: what to expect

Each flip is heads or tails with a chance of exactly 1 in 2, regardless of what came before. Over many flips the share of heads moves towards 50 %, but short streaks are normal: in ten flips, the chance of getting exactly five heads is only 252 ÷ 1,024 ≈ 24.6 % – the number of ways to choose five flips out of ten (252) divided by all 2¹⁰ = 1,024 possible sequences.

Limits of this tool

Privacy: the generator runs entirely in your browser. What you enter and the results are not sent to xmoo.app or anyone else. The share link for a list contains the entries after the # in the address; browsers do not send that part to the server, and the tool removes it from the address bar after opening.

Sources

Page last updated: 30 October 2026