Random Number Generator

Generate secure random integers within a custom range.

  • Free
  • No signup
  • Runs in your browser

How it works

How to use

Enter integer bounds and quantity, then choose whether values must be unique.

Method

Cryptographic rejection sampling avoids modulo bias.

Example

Generate five unique integers from 1 through 20.

Start by defining the population of integers

Minimum and maximum define the complete set of integers SnakTool may draw from. Both bounds are included, so a range from 1 through 6 contains six possible values: 1, 2, 3, 4, 5 and 6.

The bounds must be safe integers in ascending order. SnakTool does not silently swap a maximum that is smaller than the minimum, and decimal bounds are not accepted by this integer generator.

Inclusive range
min ≤ result ≤ max

range size = max - min + 1

The plus one is why both endpoints can be drawn

Subtracting the endpoints gives the distance between them, not the number of included integers. The range 10 through 14 has 14 - 10 + 1 = 5 possible results: 10, 11, 12, 13 and 14.

This same range size becomes important in Unique mode because it is the maximum number of distinct integers that can be returned from that interval.

Allowing repeats means every draw starts from the full range

With Unique turned off, SnakTool makes each requested draw from the complete inclusive range. A number selected earlier remains available, so a batch such as 2, 1, 2, 3, 2 is valid for a range from 1 through 3.

This is the useful model for repeated independent events such as ordinary die rolls: seeing a 6 on one draw does not remove 6 from the possibilities for the next draw. Quantity can be from 1 through 1,000.

Repeats allowed
draw → full range
draw → full range
draw → full range

previous values remain available

Unique mode changes the job to sampling without replacement

Turn on Unique when a value must appear at most once within the generated batch. Instead of making independent repeatable draws, SnakTool selects distinct positions from the range and maps those positions back to the requested minimum.

The implementation does not generate an ordinary batch and delete duplicates afterward. It constructs a set of distinct sampled positions directly, so the requested quantity is preserved when that many unique integers exist.

You cannot draw six unique values from a five-value range

For minimum 10 and maximum 14, only five distinct integers exist. A request for five unique values is possible; a request for six is rejected because no sixth distinct result exists inside the range.

This restriction applies only when uniqueness is required. With repeats allowed, a two-value range can still produce hundreds of draws because the same two integers remain eligible each time.

RangeAvailable integersMaximum unique quantity
1 to 666
10 to 1455
-2 to 255
5 to 511

Unique does not mean more random

Unique and repeatable modes answer different sampling questions. If you want ten independent die rolls, removing numbers after they appear would change the experiment. If you want three different positions from a numbered list, allowing the same position to appear twice would change that experiment instead.

Choose Unique because the task requires sampling without replacement, not because duplicate-free output is inherently a stronger form of randomness.

Cryptographic randomness is mapped into the range without modulo bias

SnakTool obtains random bits from the browser through crypto.getRandomValues(). Its secure integer helper then uses rejection sampling before mapping the random value into the requested range.

A direct modulo operation can favor some outcomes when the source space is not evenly divisible by the target range. SnakTool computes a clean divisible limit, rejects values at or above that limit, and only then applies the range mapping.

Uniform range mapping
crypto.getRandomValues()
          ↓
random value below clean divisible limit?
      ↙ no       yes ↘
   redraw          modulo range
                       ↓
              min + selected offset

Negative integers work; decimal numbers do not

A range may stay negative, cross zero or begin at zero as long as both bounds are safe integers and minimum is not greater than maximum. For example, -5 through 5 is a valid inclusive range.

Values such as 0.5 or 10.25 are not valid bounds because this tool generates integers only. It does not provide decimal-place controls or a floating-point random-number mode.

Safe integers put a real boundary around very large ranges

JavaScript numbers cannot represent every arbitrarily large integer exactly. SnakTool therefore requires safe-integer endpoints and also rejects a requested interval whose computed size cannot be represented safely.

That means two individually valid endpoints do not automatically make every enormous span between them acceptable. The generator favors exact integer behavior rather than pretending that an unsafe numeric range can be sampled precisely.

A random integer is not a fixed-width numeric string

The integer 7 has the same numeric value whether someone writes it as 7, 07 or 007, so this generator does not use leading zeroes to pad results to a chosen width.

If the requirement is specifically a fixed number of digit characters, that is a string-format problem rather than an integer-range problem. SnakTool's Random String Generator can sample digit characters by length, while Random Number Generator works from numeric minimum and maximum values.

Random selection is not an audit trail

The generator can support informal selections such as drawing distinct numbers from a list, but cryptographic random selection alone does not create entrant verification, eligibility records, reproducible audit evidence or compliance with rules for a regulated lottery or promotion.

For formal draws, use whatever process, records and independent controls the applicable rules require. The generated numbers answer the sampling request; they do not certify the surrounding contest or decision process.

Frequently asked questions about Random Number Generator

Are the minimum and maximum included in the random-number range?

Yes. SnakTool samples from an inclusive integer range, so both minimum and maximum are possible results.

What changes when I enable Unique?

Unique mode samples without replacement within that generated batch, so the same integer cannot appear twice. The requested quantity cannot exceed the number of integers available in the range.

How does SnakTool generate random numbers?

It samples integers from the inclusive minimum-to-maximum range using browser cryptographic randomness. Repeats can be allowed, or Unique mode can select distinct values without replacement.

How do I generate random numbers without duplicates?

Enable Unique. SnakTool then selects distinct integers from the range, provided the requested quantity does not exceed the number of available values.

Why can't I request more unique numbers than the range contains?

There are only max - min + 1 distinct integers in an inclusive range. Once all of them are selected, no additional different value exists inside that range.

Can I generate negative random numbers?

Yes. Negative safe integers are valid bounds, so ranges such as -100 to -50 or -5 to 5 are supported.

Does SnakTool use Math.random() for random numbers?

No. It uses crypto.getRandomValues() through its secure integer helper and does not intentionally fall back to Math.random() when secure browser randomness is unavailable.

Are Unique results guaranteed not to repeat within one batch?

Yes. Unique mode constructs a set of distinct positions, so no integer is returned twice within that generation run.

Why can a very large integer range be rejected?

The endpoints must be safe integers and the computed inclusive range size must also be safely representable. An extremely wide span can fail that second condition even when each endpoint is individually a safe integer.

Can I simulate a coin flip with numbers?

Yes. A range of 0 through 1 with Unique off provides two integer outcomes for repeated binary draws. Assign the two outcomes to the meanings you need.

Can I generate a fixed-width value such as 0042?

Not as a padded integer. Random Number Generator works with numeric values, so leading zeroes are not part of the number. A digit-string workflow is better when exact character width matters.

Can I generate hexadecimal random numbers?

The current Random Number Generator outputs ordinary integer values and does not provide a hexadecimal display mode.

How can SnakTool choose unique values without building the entire range?

Its Unique implementation samples distinct integer offsets while iterating only over the number of positions needed near the end of the range, stores those selected offsets in a set, and maps them back by adding the minimum. It does not need an array containing every integer in the range.

Browse all Generators