Random Integer Range Generator
RG-17Give an outer range and get random start and end pairs inside it, written the way you need. Switch to Random integers to draw single whole numbers from the same range.
Runs in your browser. Nothing is uploaded.
Optional: the outer range as two whole numbers, for example 1 1000 (empty means 1 to 1000)
Random ranges
How to use it
- Type the outer range as two whole numbers, for example 1 1000. Empty means 1 to 1000.
- Pick how many ranges you want and a style such as 10-50, 10 to 50 or [10, 50].
- Press Random ranges. Use Random integers to get single numbers instead.
- Tick Sort by start to list the ranges in order, then copy the result.
What a random range is here
The tool draws two whole numbers from your outer range, each one equally likely, and writes the smaller first. That gives you a start and an end that always lie inside the outer range. The two ends are drawn independently, so you get a mix of short and long ranges with no rule about their length. With Start and end differ ticked, a pair where both numbers match is drawn again.
Uses and limits
Ranges like these help when you test code that takes intervals, such as page ranges, date offsets, price bands or slice indexes. The tool does not check that ranges avoid each other, so they can overlap or nest. Both ends of the outer range can appear. Numbers larger than 2^53 are not rounded, because they are handled as exact integers. For plain random numbers with decimals and a separator choice, the random number generator has more options.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Enter two whole numbers: the lowest and the highest, for example 1 100. | The box does not hold exactly two numbers. | Type the lowest and highest number, or clear the box. |
The lowest number is higher than the highest number. | The outer range is written backwards. | Put the smaller number first. |
The range has only one number, so the two ends cannot be different. | Start and end differ is ticked but the outer range is a single number. | Widen the outer range or untick Start and end differ. |
Questions people ask
What is a random integer range?
It is a pair of whole numbers, a start and an end, that you pick at random. For example 120-480 is one range. Here, both ends come from the outer range you type, and the smaller number is always written first.
Can the start and end be the same number?
Yes, unless you tick Start and end differ, which is on by default. When it is on, a pair with equal numbers is thrown away and drawn again, so every range spans at least two numbers.
How do I get single random integers instead?
Press Random integers rather than Random ranges. It draws whole numbers from the same outer range, and you can tick No repeated integers to get different values only.
Will the ranges overlap?
They can. Each range is drawn on its own, so two ranges may overlap or one may contain another. The tool does not try to make them separate. If you need separate blocks, sort by start and merge them in your own code.
Which range styles can I choose?
Dash (10-50), the word to (10 to 50), two dots (10..50), brackets ([10, 50]) and comma (10,50). Pick the one your code or spreadsheet expects. Negative numbers are written with their minus sign, for example -5-3 in dash style.
Does it work with very large numbers?
Yes. Numbers are exact integers, so 100000000000000000000 stays exact instead of being rounded to the nearest value a normal JavaScript number can hold. The limit is 400 digits for each number you type.
About this tool
Values are made in your browser with crypto.getRandomValues and rejection sampling, so no value is favored, and nothing is sent anywhere or stored. Random ranges draws two whole numbers from the outer range you type and writes the smaller one first, so each line is a start and an end that lie inside it. The two ends are drawn independently, so short and long ranges both appear and there is no rule about the length. "Start and end differ" redraws until they are not equal. Random integers instead returns single whole numbers from the same range, optionally without repeats. Both include the lowest and the highest number and work with numbers larger than 2^53 without rounding. Ranges are not checked for overlap with each other.