The random number generator above produces integers or decimals anywhere in a range you set, in whatever quantity you need, with or without repeats. It draws from crypto.getRandomValues, the browser's cryptographically strong random source, and it uses rejection sampling rather than a modulo operation so that every value in the range is genuinely equally likely. Where a browser does not provide the crypto interface, it says so plainly in the result panel rather than pretending nothing changed.
Arb Digital publishes this among its free developer tools because most quick random-number implementations contain the same small statistical flaw, and it is invisible until somebody looks for it. Getting the distribution right is not difficult, but it does require doing something other than the obvious thing, and the obvious thing is what almost every tutorial shows.
What This Random Number Generator Does
The tool takes a minimum, a maximum and a count, and returns that many values. Integer mode treats both endpoints as inclusive, so a range of 1 to 100 has exactly one hundred possible values. Decimal mode returns values in the interval between the endpoints rounded to the number of places you choose. The no-repeats option draws without replacement, which is the behaviour you want for lottery-style selection and the behaviour you do not want when simulating independent events.
Two details are surfaced rather than hidden. The randomness source is displayed, so you always know whether you are getting cryptographic randomness, a deterministic seeded sequence, or a fallback. And the count of possible values in the range is shown next to the count of numbers drawn, because the relationship between those two figures is what determines whether unique selection is even possible.
Boundary worth stating: this generates numbers from a numeric range. If you want to choose among a list of names, options or items you have typed out, our random picker wheel does that job instead. For simulated dice with their own notation and conventions, the dice roller is the right page.
How to Use It
- Set the range. Both ends are included in integer mode, and the tool swaps them silently if you enter the maximum first.
- Choose how many numbers you need and whether they should be integers or decimals. Decimal places only apply in decimal mode.
- Tick no repeats for draws without replacement. If you ask for more unique numbers than the range contains, the tool tells you rather than looping forever.
- Leave the seed blank unless you specifically want a repeatable sequence. Seeded output is deterministic by design and is not suitable for anything that must be unpredictable.
- Press Generate for a fresh draw. Every press produces a new result; changing sort order alone does not redraw.
How the Numbers Are Produced
Unseeded, the tool asks the browser for 32-bit unsigned integers through crypto.getRandomValues. The W3C Web Cryptography specification defines this method as generating cryptographically strong random values, and notes that implementations should use well-established cryptographic pseudo-random generators seeded with high-quality entropy from an operating-system source. That is a materially different guarantee from Math.random(), which is only required to be statistically reasonable and is explicitly not suitable for security purposes.
Mapping a 32-bit value onto a smaller range is where the care is needed. The tool computes the range size, then discards any drawn value that falls into the incomplete final block before taking the remainder. That discard is what makes the result uniform, and it is described in the next section because it is the part most implementations get wrong.
Seeded mode replaces the source with a small deterministic generator initialised from your seed string. It is fast, repeatable and entirely predictable, which is exactly right for reproducing a test fixture and exactly wrong for anything else. The distinction between a deterministic generator and a genuinely unpredictable one is the subject of NIST Special Publication 800-90A Revision 1, Recommendation for Random Number Generation Using Deterministic Random Bit Generators.
Modulo Bias, and Why the Obvious Code Is Wrong
The standard way to squeeze a large random value into a small range is the remainder operator: take a random 32-bit number and compute it modulo the range size. It is one line, it looks correct, and it produces a subtly uneven distribution whenever the range does not divide the source evenly.
Work it through with tiny numbers. Suppose your source produces values 0 to 9 uniformly and you want a number from 0 to 2, so you take the value modulo 3. Values 0, 3, 6 and 9 all map to 0. Values 1, 4 and 7 map to 1. Values 2, 5 and 8 map to 2. Outcome 0 arrives four times in ten while the others arrive three times each — a 33% excess. The same effect exists with a 32-bit source and any range that is not a power of two; it is simply smaller. For a range of 100 the bias is around one part in forty million, which never shows up in casual testing and does show up in a shuffle used millions of times, in a load balancer, or in anything an adversary is studying.
The fix is rejection sampling. Compute the largest multiple of the range that fits inside the source's span, discard any draw at or above that limit, and only then take the remainder. In the toy example, you would discard the value 9 and re-draw, leaving 0 to 8 which divides evenly by 3. The cost is an occasional extra draw — on average well under one per number for ordinary ranges — and the benefit is an exactly uniform distribution. This tool does that on every integer it produces.
Why Seeded Output Is Not Random
A seeded generator produces a sequence that looks random by every casual test and is completely determined by the seed. Give it the same seed tomorrow and you get the same numbers in the same order. That property is valuable: it makes a simulation reproducible, lets a failing test be re-run identically, and allows two people to generate the same dataset without exchanging it.
It is also the property that makes seeded output useless for anything that must be unpredictable. If an attacker can guess or observe the seed — and seeds derived from the current time are guessable within a narrow window — every value the generator will ever produce is known. RFC 4086, the IETF's Randomness Requirements for Security, puts the point sharply: using pseudo-random processes to generate secret quantities can result in pseudo-security, because reproducing the conditions that generated a secret is often far cheaper than searching the space it nominally occupies. Never use a seeded generator for tokens, passwords, keys, or anything with money attached. Use the password generator for those.
With and Without Replacement, and Why It Matters
Independent draws and unique draws answer different questions, and choosing the wrong one quietly invalidates a result. Rolling a die repeatedly is drawing with replacement: each roll is independent and repeats are expected. Picking six lottery numbers is drawing without replacement: once a number is taken it is gone, and later draws are conditioned on earlier ones.
People are surprised by how often repeats appear in independent draws. Ask for six numbers between 1 and 100 with replacement and there is roughly a 14% chance that at least two of them match — this is the birthday problem, and the collision probability grows far faster than intuition suggests. Seeing a duplicate is not evidence that the generator is broken; seeing no duplicates in a long run would be. The probability calculator is the tool for working out those collision odds directly.
Where Random Numbers Are the Wrong Tool
Two practical cautions. First, random selection is not the same as fair selection when the population is not uniform — drawing a random customer from a list gives every row an equal chance, which is rarely what "fair" means if the rows represent different order values or regions. Stratifying first and drawing within strata is usually the honest approach.
Second, rounding changes distributions. In decimal mode, rounding to two places assigns every value in a small interval to the nearest representable number, and the two endpoints of the range receive only half an interval each. For most uses this is irrelevant; for anything statistical, generate at full precision and round only for display. If your goal is a shuffled order rather than a set of values, generate a permutation directly rather than assigning random numbers and sorting by them, which is the classic way to introduce bias into what should have been a clean shuffle.
Arb Digital builds fast, correct, secure websites — the kind where the small things behave the way the documentation says they do.
See Web Design Services Talk to Arb DigitalCommon Mistakes to Avoid
- Using a modulo operation to fit a range. It skews the distribution toward the lower values whenever the range does not divide the source evenly; rejection sampling fixes it.
- Using Math.random for anything secret. It is not a cryptographic generator and is not required to be unpredictable, whatever it looks like in testing.
- Seeding from the current time and calling it random. A time-based seed is guessable within a narrow window, which makes the whole sequence recoverable.
- Treating repeats as a bug. Independent draws produce duplicates far more often than intuition suggests; if you need uniqueness, ask for it explicitly.
- Shuffling by sorting on random keys. It is a well-known source of bias; generate a permutation directly instead.
Related Free Tools From Arb Digital
To pick from a list of items rather than a numeric range, use the random picker wheel. The dice roller covers the most common simulated device. For unpredictable values with a security purpose, the password generator is the right tool, and the password entropy calculator scores how unpredictable a result really is. On the statistics side, the probability calculator answers the questions that usually follow a draw. The full free online tools hub lists the rest.
Frequently Asked Questions
They come from crypto.getRandomValues, which the Web Cryptography specification defines as producing cryptographically strong values seeded from an operating-system entropy source. That is not the same as physical randomness, but it is unpredictable in practice and far stronger than an ordinary pseudo-random function.
It is the uneven distribution you get when you fit a large random value into a smaller range using the remainder operator. Unless the range divides the source exactly, the lowest values occur slightly more often. Rejection sampling removes the bias by discarding draws that fall outside a clean multiple of the range.
The tool falls back to Math.random and states clearly in the result panel that it has done so. Math.random is adequate for games and casual use but is not a cryptographic generator, so a fallback result should never be used for anything security-related.
Entering a seed switches to a deterministic generator that produces the same sequence every time for that seed. It is useful for reproducing test data or sharing an identical dataset, and it is unsuitable for anything that needs to be unpredictable.
Yes, in integer mode both endpoints are inclusive, so a range of 1 to 100 has exactly one hundred possible outcomes. In decimal mode values fall within the interval and are then rounded to the number of places you selected.
Because independent draws allow repeats, and they occur more often than people expect. Six numbers drawn from 1 to 100 have roughly a 14% chance of containing a duplicate. Tick the no-repeats option to draw without replacement instead.
No. Every number is produced locally by JavaScript running in your browser. The page makes no network request, stores nothing, and logs nothing, so no result ever leaves your device.
It is suitable for informal draws and produces an unbiased result. Formal or regulated draws normally require an auditable, certified process with documented procedures, which no web page can provide on its own.