Skip to content

Random Number Generator

Creator

Syeda Kinza Batool, Co-founder

Reviewer

Ashna Bashir, AI/ML Engineer
Updated

Random Number Generator

Comprehensive Version

Decimals allowed

Decimals allowed

Up to 200

Result type

Set a minimum, a maximum and how many numbers you need, then press Generate. Each press draws a fresh set of whole numbers from within your range, and you can choose whether the same number is allowed to come up more than once. It works for anything from running a plain random number generator 1-100 (or a number generator 1-100 for a shorter search) to drawing a full set of unique raffle winners or lottery-style picks.

Need more than whole numbers? Use the Comprehensive Version card below for lower and upper limits that can be decimals, a choice between Integer and Decimal output, and, in Decimal mode, a precision setting for exactly how many digits follow the decimal point, even hundreds of them.

How the random number generator handles range and duplicates

Every number this tool produces is a whole number somewhere between the min and max you enter, both ends included. Behind the scenes, each draw scales a random fraction between 0 and 1 up to the width of your range, then rounds down to land on one whole number inside it, so every value in the range has an equal chance of being picked on any single draw.

The “allow duplicate numbers” option decides whether that draw happens with or without replacement. With duplicates allowed, each number is drawn completely independently of the ones before it, so the same value can appear more than once in your results, exactly like rolling a die several times in a row. With duplicates turned off, the tool instead shuffles every possible value in your range and hands you the first however-many you asked for, so no value can repeat, the same way a raffle drum or a lottery machine never draws the same ball twice in one round.

That distinction has a hard limit built into it. If duplicates are off, the range has to contain at least as many possible values as the count you are asking for. Ask for 15 unique numbers from a range of 1 to 10, and the request fails outright, naming the range size, rather than silently returning fewer numbers than you asked for or getting stuck trying to find one more unique value that does not exist.

The Comprehensive Version: decimal limits and adjustable precision

The Comprehensive Version card starts from the same idea as the Random Number Generator card above it, a lower limit and an upper limit, but both fields now accept decimals, and a Result Type toggle lets you choose whether the output should be a whole number or a decimal. It is the version to reach for whenever the plain min/max/count fields above it are not quite enough, whether that means a range with a fractional edge, like 1.5 to 9.5, or a result that needs a fractional part of its own.

With Integer selected, decimal limits are narrowed to the whole numbers they actually contain: a lower limit of 1.5 and an upper limit of 4.2 narrows to the range 2 to 4, since neither 1 nor 5 falls inside what you typed. If no whole number sits inside your limits at all, a lower limit of 1.1 and an upper limit of 1.9, say, the tool says so rather than rounding to a number you never asked for. This is also the card to use for a longer code-style number, such as a 4-digit or 6-digit random number: set the lower limit to 1000 and the upper limit to 9999 for a 4-digit result, or 100000 to 999999 for 6 digits.

With Decimal selected, the Precision field sets exactly how many digits follow the decimal point, from a single digit up to several hundred. Every one of those digits is generated independently and assembled as text, not calculated as an ordinary floating-point number, which is what makes a high precision setting possible at all. A plain number only reliably holds around 15 significant digits before more of them stop carrying any real information, purely because of how computers store floating-point values, so a precision far beyond that would be meaningless, or would simply fail, if it were computed the usual way. Generating each digit directly sidesteps that ceiling entirely, at one honest trade-off: the result is a piece of text built to look like a very precise decimal for you to read or copy, not a number a spreadsheet formula could do further maths on.

Quick settings for common picks

Every pick below is the same two fields, Min and Max, with Count set to 1. Turning duplicates off and raising Count gives a non repeating random number list, and a range such as 1 to 49 with six numbers works as a lottery-style quick pick. For dice that need rolling in a game, the dice roller handles several dice at once.

Min and Max settings for common picks, dice and coin flips
What you wantMinMaxNote
Pick a number 1-10110Quick decisions and guessing games
Pick a number 1-1001100Classic guess-the-number range
Pick a number 1-515Small groups and rating picks
Pick a number 1-414Also a random number from 1-4 for four options
Pick a number 1-20120One roll of a twenty-sided die
Number generator 1 to 16116Drawing a place in a 16-slot bracket
Roll a d616One six-sided die; draw again for each extra die
Roll a d414One four-sided die
3 sided die13Rock, paper, scissors or any three-way pick
5 sided dice15One five-sided die
Flip a coin121 for heads, 2 for tails

Common uses

Between the two cards, a handful of controls cover a surprising number of everyday situations. A few of the most common:

  • Picking a single random number. Set min and max to the bounds you need, count to 1, and press Generate for a one-off pick, whether that means a full random number generator 1-100 request or a quick pick a number between 1 and 10 to decide who goes first in a game.
  • Raffle or giveaway winners. Turn duplicates off, set count to how many winners you need, and set the range to match your entry numbers, so nobody can be drawn twice: a random number generator no repeats setup, by design.
  • Splitting people into teams. Assign each person a number from 1 up to the group size, generate that many unique numbers, and use the order they come out in to build teams or a random speaking order.
  • Lottery-style number sets. Set the range to match your lottery’s actual number pool and generate a unique set the same size as a real draw, useful for practicing picks or generating a set of numbers to play.
  • Simulating dice or repeated draws. Leave duplicates allowed and set the range to match a die or spinner, then generate several numbers at once to simulate a series of rolls. For dice-shaped output specifically, including a dnd dice roller for tabletop games with d4, d8, d20 and other polyhedral dice, the dice roller is the dedicated tool for that.
  • Multi-digit codes. Use the Comprehensive Version in Integer mode with a range like 1000 to 9999 for a 4-digit random number, or 100000 to 999999 to use it as a 6 digit random number generator, whenever you need a placeholder number that is not meant to double as a real security credential.
  • Decimals with a specific number of digits. Use the Comprehensive Version in Decimal mode when a whole number will not do, such as generating sample measurements or test data that needs a consistent number of decimal places.

Choosing a sensible range and count

Min and max only need to satisfy one rule: min cannot be greater than max. Both can be negative, both can be the same number, and the range does not need to start at zero or one. A range of -10 to 10 is just as valid as 1 to 100, which is useful if you are simulating something like a temperature swing or a profit-and-loss scenario rather than a simple pick.

How many numbers you ask for interacts with the duplicates setting. With duplicates allowed, count can be any size, since the same value is always free to come up again; with duplicates off, count is capped by how many distinct values exist in your range, so a range of 1 to 6 can never return more than 6 unique numbers. Hit that ceiling and either widen the range or lower the count.

It is also worth deciding up front whether order matters. If you are drawing raffle winners in the order they should be announced, treat the first number back as the first winner; if only which numbers were picked matters, feel free to sort the results yourself afterward, since the tool does not reorder them for you.

An honest limitation: this is not cryptographically secure

Both versions on this page are built on JavaScript’s standard Math.random() function, including the independent digit draws behind the Comprehensive Version’s Decimal mode. That makes it fast, and more than good enough for games, classroom demonstrations, raffles, and everyday decision-making. It is not, however, built to resist someone who is deliberately trying to predict its output.

Math.random() is a pseudorandom number generator: it produces numbers that look random and pass ordinary statistical tests, but they are generated by a deterministic algorithm from an internal seed, not sampled from real-world physical randomness. In some JavaScript engines, enough observed outputs can in principle let someone reconstruct that internal state and predict future numbers. For picking a raffle winner or rolling a virtual die, that theoretical weakness is irrelevant. For anything where a wrong answer could let someone steal money or access, it matters a great deal.

So plainly: do not use this tool, or any tool built on Math.random(), to generate passwords, encryption keys, PINs, security tokens, or anything else where predictability would be a security failure. Use a generator built specifically for that purpose, one based on a cryptographically secure source such as the Web Crypto API, instead.

Frequently asked questions

Is this generator truly random?

It uses your browser's built-in Math.random() function, which is a pseudorandom number generator: fast, unpredictable enough for everyday use, and good enough that you cannot practically guess the next number from the previous ones. It is not derived from physical noise the way a hardware random number generator is, but for picking numbers, running a raffle or settling a tie, that difference does not matter.

Can I use this for a lottery-style draw or raffle?

Yes. Turn off "Allow duplicate numbers" and set how many numbers you need, and every number in the result is guaranteed to be distinct, the same way lottery balls are drawn without replacement. Set min and max to match your actual lottery's number range for a realistic set of picks.

Why would I want duplicates allowed?

Turning duplicates on models drawing with replacement, like rolling a die more than once or picking a random number in a game where the same result can come up again. If you are simulating repeated independent events rather than drawing unique items, duplicates should usually stay on.

Why would I want duplicates turned off?

Turn duplicates off whenever each result has to be a distinct item: picking unique raffle winners, assigning people to teams without repeats, or drawing lottery numbers where the same ball cannot be drawn twice in one round.

Is this safe to use for generating a password or a secret key?

No. Both versions on this page use Math.random(), which is not cryptographically secure: it is not built to resist someone predicting future or past outputs, which is exactly what a password or a cryptographic key needs to resist. Use a dedicated cryptographically secure generator, such as one built on the Web Crypto API, for anything security-related.

Why does it say I cannot generate more unique numbers than the range allows?

With duplicates turned off in the Basic version, every number in the result has to be different, so there is a hard ceiling: a range from 1 to 10 only contains 10 distinct whole numbers, so you cannot ask for 11 unique picks from it. Either widen the range or lower how many numbers you are asking for.

Can min and max be negative, or the same number?

Yes to both, in either version. Min (or the Comprehensive version's lower limit) can be any number less than or equal to max, including negative values, so a range like -10 to 10 works fine. If the two ends are equal, the range has exactly one possible value, so asking for one number returns that value every time, and the Basic version asking for more than one with duplicates off will fail since there is nowhere for a second distinct value to come from.

Do decimal values work for min or max?

Not in the Random Number Generator card, which only produces whole numbers and only accepts whole numbers for min and max. Use the Comprehensive Version card instead: its lower and upper limit fields accept decimals, and setting the result type to Decimal generates numbers with a fractional part instead of whole numbers.

What does the Precision field do in the Comprehensive Version?

It sets how many digits appear after the decimal point in Decimal mode, from 1 up to several hundred. Each of those digits is drawn independently, the same way each whole number is drawn in Integer mode, so asking for 50 digits of precision is exactly as exact as asking for 2, never rounded and never padded with repeated filler digits.

Why generate decimal digits as text instead of as an actual number?

A standard number in JavaScript (and in most programming languages) only reliably holds around 15 to 17 significant digits before further digits stop meaning anything, purely because of how computers store floating-point values. A precision setting much beyond that would silently lose accuracy, or fail outright, if the result were computed as ordinary arithmetic. Building the digits directly, one independently random digit at a time, sidesteps that limit completely, which is why this tool can honestly offer up to several hundred digits of precision. Since the result here is only ever displayed and never fed back into a calculation, there is no downside to generating it this way.

Is this the same thing as a spinning number wheel?

Not visually. A number wheel, or "spin the wheel" generator, shows the pick as an animated spinning wheel that lands on one value; this page shows the result as plain text instead. Underneath, though, both do the identical job: picking one or more numbers at random from a range you set, with every value in that range equally likely to come up. If you specifically want the spinning-wheel animation, look for a dedicated wheel tool; if you just want the fair random pick itself, this generator produces the same result without the animation.

Related tools: Fraction Calculator, Long Division Calculator and Binary Calculator. More are grouped under Math Calculators, and every tool on the site is listed at all calculators.