ToolNimba

๐ŸŽฒ Random Number Generator 1 to 40

Shihab Mia By Shihab Mia ยท Updated 2026-07-26

Result
-

This is a free online random number generator preset to the 1 to 40 range, and a result is already sitting there the moment the page loads. Minimum is fixed at 1 and maximum at 40 by default, though both fields stay editable if you want a different range. A pool of 40 fits things like a Monopoly-sized board, a classroom or small office of about 40 people, or a raffle with 40 numbered tickets. Set how many numbers you want, choose whether repeats are allowed, and click Generate for a fresh, unbiased result.

What is the Random Number Generator 1-40?

A range of 1 to 40 covers exactly 40 whole numbers. That size shows up in a few genuine everyday spots: a standard Monopoly board has 40 spaces, so this range can stand in for a random square pick; classrooms, small departments, and clubs often land somewhere around 40 members; and plenty of raffles, giveaways, or numbered-ticket draws use a round batch of 40 entries. It is not tied to any specific lottery format, so treat it as a general-purpose "pick one of 40" or "pick several of 40" tool rather than a lottery number generator.

Fairness comes from how each number is drawn, not from the size of the range. This tool reads a 32-bit value from the Web Crypto API, the same cryptographically secure source browsers use for security-sensitive tasks, rather than a simple seeded formula. Taking that raw value modulo 40 would introduce a small bias, because 40 does not divide evenly into the full 32-bit space, so a handful of low numbers would come up very slightly more often than the high ones. This tool avoids that with rejection sampling: it discards the few values that fall in the uneven remainder and only keeps values from a block that divides cleanly by 40. The result is that every one of the 40 numbers carries exactly the same 1-in-40 chance on each draw.

The duplicates toggle changes how repeated draws behave. With Allow duplicates ticked, each number is picked independently, so the same value can appear more than once, similar to rolling a 40-sided die several times in a row. Untick it and the tool switches to drawing without replacement using a partial Fisher-Yates shuffle, the standard unbiased way to select a unique subset, so no number repeats. Because unique mode pulls from a fixed pool of 40 values, you cannot request more than 40 unique numbers from this range; ask for more and the tool tells you plainly instead of guessing or looping.

The Sort results checkbox does not change which numbers get drawn, only how they are listed afterward, arranging them from lowest to highest instead of in draw order. That is handy when you are checking a set of picked numbers, such as winning ticket numbers, against a numbered list.

When to use it

  • Picking a random square on a Monopoly-style board, since a standard board has 40 spaces.
  • Drawing a winner from a raffle, giveaway, or numbered-ticket draw with up to 40 entries.
  • Choosing a random student, employee, or team member from a class or department of around 40 people.
  • Assigning a random turn order, table number, or seat position in a workshop or small event.
  • Running a quick pick-a-number party game or icebreaker where guests guess a number from 1 to 40.
  • Sampling a handful of unique rows or entries from a list that has exactly 40 items.

How to use the Random Number Generator 1-40

  1. The minimum and maximum are already set to 1 and 40, so a result shows as soon as the page loads.
  2. Change how many numbers you want in the "How many" field if you need more than one.
  3. Tick Allow duplicates for independent picks, or untick it for unique numbers with no repeats.
  4. Optionally tick Sort results to list the numbers from lowest to highest.
  5. Click Generate for a new draw, then click Copy to put the numbers on your clipboard.

Formula & method

There are 40 equally likely whole numbers in the range 1 to 40 inclusive (max - min + 1 = 40). Each pick is drawn as an unbiased integer using rejection sampling on a 32-bit crypto value, discarding the uneven tail so all 40 values share exactly a 1-in-40 chance. Unique mode draws without replacement with a partial Fisher-Yates shuffle over the 40-value pool.
Range: 1 to 401204040 equally likely whole numbers

Worked examples

Pick a single random number for a quick decision or icebreaker.

  1. Leave minimum at 1 and maximum at 40.
  2. Leave how many at 1 and keep duplicates allowed.
  3. The tool draws one unbiased number out of 40 equally likely values.

Result: One number from 1 to 40, for example 23

Draw 5 unique winners from a 40-ticket raffle.

  1. Leave minimum at 1 and maximum at 40.
  2. Set how many to 5 and untick Allow duplicates.
  3. The tool draws 5 distinct numbers without replacement, so no ticket is picked twice.
  4. Tick Sort results to list the winning ticket numbers in order.

Result: Five different numbers between 1 and 40 in ascending order, for example 4, 11, 19, 28, 36

Nearby ranges and what they suit

RangePossible valuesTypical use
1 to 4040A Monopoly-style board, a class of about 40, a 40-entry raffle
1 to 3030A day of the month, a smaller class or raffle
1 to 5050A larger raffle or numbered-ticket draw
1 to 2020A smaller class, team, or D20-style pick
1 to 66A single six-sided die

How the duplicates toggle changes the result

SettingMethodCan a number repeat?
Allow duplicates onEach pick is independent (with replacement)Yes
Allow duplicates offDraw without replacement (shuffle), max 40 numbersNo

Common mistakes to avoid

  • Requesting more than 40 unique numbers. With duplicates off, the pool only holds 40 values, so you cannot draw 45 unique numbers from a 1 to 40 range. Widen the range or allow duplicates if you need more picks than that.
  • Assuming 40 is excluded from the range. Both the minimum and the maximum are included. A 1 to 40 range can return 1 or 40 just as easily as any number in between, giving the full 40 possible values.
  • Treating this as a specific lottery generator. A 1 to 40 range is not tied to a particular lottery format. Use it for board-game squares, raffles, and group selections rather than assuming it matches a lottery you play.
  • Expecting a perfectly even spread in a short run. True randomness clusters. Drawing a handful of numbers from 1 to 40 may show a repeat or a gap in one part of the range by chance. That evens out over many draws and does not indicate a fault.

Glossary

Random number generator (RNG)
A process that produces numbers that are hard to predict, with each allowed value equally likely within the chosen range.
Uniform distribution
A spread where every value in the range, here each of the 40 numbers, has exactly the same probability of being chosen.
Cryptographically secure
Randomness drawn from a high-quality system source that cannot be predicted or reproduced, as provided by the Web Crypto API.
With and without replacement
With replacement means each pick is independent and numbers can repeat. Without replacement means each of the 40 values is used at most once.
Modulo bias
A subtle skew that appears when a large random value is reduced with the remainder operator and the range does not divide evenly, making some numbers slightly more likely.
Rejection sampling
A technique that discards the small uneven slice of raw random values so the remaining values map onto the target range, here 1 to 40, with no bias.

Frequently asked questions

How do I generate a random number between 1 and 40?

This page is already preset to that exact range, so a result shows the moment it loads. Click Generate for a fresh unbiased pick any time, or adjust the minimum and maximum if you need a different range.

Is every number from 1 to 40 equally likely?

Yes. The tool draws from the Web Crypto API and uses rejection sampling to remove modulo bias, so each of the 40 numbers has exactly the same 1-in-40 chance on every draw.

Can I generate more than one number from 1 to 40 at once?

Yes. Raise the "How many" field to any amount you need. With duplicates allowed there is no upper limit; with duplicates switched off you can request at most 40 unique numbers.

Can I get unique numbers with no repeats in this range?

Yes. Untick Allow duplicates and the tool draws without replacement using a Fisher-Yates shuffle, so no number appears twice. You cannot ask for more than 40 unique numbers, since only 40 values exist.

Can I change the range away from 1 to 40?

Yes. The minimum and maximum fields are preset to 1 and 40 for convenience, but both stay fully editable, so you can widen or narrow the range without leaving the page.

Does this tool send my numbers anywhere?

No. All generation happens locally in your browser using plain JavaScript and the built-in Web Crypto API. Nothing you enter and no result is uploaded or sent over a network.