Random Numbers

Random number generator

Ready —
From
To
How many
Seed
Uniform · rejection sampled, no modulo bias

Nothing yet. Results appear here so you can prove what came up.

This generator draws whole numbers from a range you choose, using the browser’s cryptographic randomness with rejection sampling so that every value is equally likely. Turn on "No repeats" to draw distinct numbers — six from forty-nine, for instance — rather than independent draws that may collide. The range runs from negative to positive, up to nine quadrillion wide.

How to use it

1 Set the range and how many numbers you want.
2 Decide whether repeats are allowed. Lottery-style draws want them off; dice-style draws want them on.
3 Sort the result if you want it in order rather than in draw order.
4 Press Generate. Copy all takes the whole list, one per line.

Most naive generators take a random 32-bit value and apply a modulus, which quietly favours the low end of any range whose width is not a power of two. This one rejects and redraws the small slice of values that would cause the bias, so a range of 1 to 6 comes out exactly uniform and not merely close to it. The difference is invisible in ten draws and measurable in ten thousand.

A range is also how you draw things that are not really numbers. A random date is a day offset added to a start date, a random page is a page number, and a random row of a spreadsheet is a row number. A window of the day works the same way, as minutes past midnight: 540 to 1020 is 09:00 to 17:00, and dividing the result by 60 gives the hour with the minutes as the remainder. For a time across the whole day the random time generator does that formatting for you and draws all 1,440 minutes; this page is what you want when the window is narrower than the day, or wraps past midnight, since a single range cannot.

What people use it for

  • Drawing lottery-style numbers, six distinct from forty-nine
  • Running a prize draw someone else can verify from the seed
  • Picking a random time inside a window, as minutes past midnight
  • Sampling row numbers out of a spreadsheet
  • Filling test data with values in a known range

Questions

Yes. From 1 to 100 can produce 1 and can produce 100.

MDN, Crypto.getRandomValues()NIST SP 800-90A, recommendation for random number generation
Was this tool any good?
Internal signal only · I use it to find the tools worth rebuilding