Generate Random Integer Range

Pick one random integer from an inclusive range, using secure browser randomness when it is available.

Result
9

Generated with secure browser randomness when available.

Inclusive Span
100
Minimum
1
Maximum
100

How The Generator Works

The generator treats your minimum and maximum as an inclusive range, measures the number of possible integers, and then selects one offset at random.

A rejection-sampling step is used with `crypto.getRandomValues()` so every integer in the range stays evenly distributed, as long as the range stays within JavaScript safe integers and a 32-bit inclusive span.

Quick Examples

A 1 to 10 range is useful for dice-like picks or quick demonstrations.
Negative-to-positive ranges are helpful when testing signed integer inputs.
A larger span creates more possible outcomes without changing the basic logic.
Inclusive ranges make the result easier to reason about for both endpoints.

Frequently Asked Questions

Does the maximum value count?

Yes. Both endpoints are included, so a range from 1 to 10 can return either 1 or 10.

Why round the inputs down?

This tool is designed for integers, so any decimal input is normalized to its whole-number floor.

Can I use negative numbers?

Yes. Negative values work as long as the minimum is not greater than the maximum.

What is this useful for?

It is handy for random picks, tests, fixtures, games, and any logic that needs one random integer.

Useful Notes

Inclusive ranges are often easier to explain than half-open ranges.

Uniform integer selection matters when you want every value to be equally likely.

Single-value ranges are valid and always return that one integer.

Very large ranges are rejected so the generator does not enter an invalid rejection loop.

Related Tools