FormatterHQ

Random Integer Generator for Whole Numbers

This random integer generator returns whole numbers only, each equally likely between two inclusive bounds. It starts at -1000 to 1000, so negatives, zero and positives all appear.

Loading tool…
Ready.

How to use the Random Integer Generator

  1. Set Min and Max; both are included and either may be negative.
  2. Enter how many integers you want, from 1 to 10,000.
  3. Tick Unique values to rule out repeats, or leave it off for independent draws.
  4. Choose a sort order and the separator used by Copy all and Download.
  5. Press Generate, or change a setting to get a fresh list.

What the random integer generator produces

The random integer generator returns whole numbers only: no fractions, no decimal places, just values such as -412, 0 or 87. Both bounds are included, so the default range of -1000 to 1000 holds 2,001 possible values. It shares its engine with the Random Number Generator, which starts at 1 to 100 and suits everyday picks such as raffles. Use this page when you care about how the integers behave: signed values, repeats, unique samples and test data. If your question is mainly about setting up a range correctly, the random integer range page covers inclusive bounds and off-by-one errors in code.

Uniform: every integer has the same chance

Each value is drawn with probability 1 / (Max − Min + 1). The generator reads 32-bit values from the browser's crypto.getRandomValues and throws away any value that would give some integers a slightly larger share, a technique called rejection sampling. For ranges wider than about four billion values, it combines two readings into a 53-bit number and applies the same rule. The result has no bias toward small numbers, no pattern you could predict from earlier output and no seed that repeats between visits.

Decimal bounds are rounded inward

If you type a bound with a fractional part, Min is rounded up and Max is rounded down, so the output never leaves the interval you entered. Real output for Min 1.5 and Max 6.5:

3 4 5 2 2 6 3 4 3 4

Only 2 to 6 can appear. With Min 1.2 and Max 1.8 there is no integer in between, and the page reports Min must not be greater than max. If you actually want fractional values, use the Random Decimal Generator.

Repeats versus unique integers

With Unique values unticked, every draw is independent, so duplicates are expected. Here are twelve real values from 0 to 255:

245 70 200 95 102 115 207 248 119 154 202 207

The value 207 appears twice. That is not a flaw: the chance of at least one repeat among k draws from N values is about 1 − e^(−k(k−1) / 2N), which for 12 draws from 256 values comes to roughly 23%. When you tick Unique values, a draw that repeats an earlier value is discarded and drawn again, which is equivalent to sampling without replacement. The count can then be no larger than the number of integers in the range; asking for more produces an error rather than a padded list.

Sampling and test data recipes

  • Audit a sample of records: Min 1, Max 1200, How many 50, Unique values on, Sort ascending, Separator comma. Paste the result into a query such as WHERE id IN (…). If some IDs have been deleted, sample row positions instead of IDs.
  • Exercise numeric fields: generate values across the full range of the column type, then add the boundary values yourself, since a random sample rarely hits the exact minimum or maximum.
  • Byte-sized values: 0 to 255 gives random byte values you can convert with Decimal to Binary or Decimal to Hex.
  • Statistics practice: generate 1,000 integers from 1 to 10 and compare their average with the expected 5.5. Small samples wander noticeably; larger ones settle close to the expected value.
Integer typeMinMax
8-bit unsigned0255
8-bit signed-128127
16-bit unsigned065535
16-bit signed-3276832767
32-bit unsigned04294967295
32-bit signed-21474836482147483647

Limits and output

Each run produces 1 to 10,000 integers. The difference between Max and Min may be at most 9,007,199,254,740,991; wider ranges are refused with a message. On screen, every integer sits in its own box with a copy button. The Separator setting (new line, comma or space) decides how Copy all and Download join the list, and the sort option orders values numerically. Download saves a plain text file named random-integer-generator.txt. Changing any setting produces a new list straight away, and Ctrl/⌘ + Enter does the same from the keyboard. Everything is generated locally in your browser.

Random integer generator in Python

The random module covers every option on this page. random.randint(a, b) returns an integer with both ends included, exactly like the Min and Max fields above, while random.randrange(a, b) stops one short of b; mixing the two up is the usual off-by-one bug. For values without repeats use random.sample(), which raises ValueError when you ask for more integers than the range holds. The module is built for simulations and test data, so draw tokens and PINs from secrets instead.

import random
import secrets

print(random.randint(-1000, 1000))                 # one integer, both ends included
print([random.randint(1, 6) for _ in range(10)])   # ten dice rolls, repeats allowed
print(random.sample(range(1, 50), k=6))            # six unique integers from 1 to 49
print(sorted(random.sample(range(-1000, 1001), k=10)))  # unique and sorted

# randrange() leaves the upper bound out, like range()
print(random.randrange(0, 10))                     # 0 to 9

# For tokens, PINs and anything security related
print(secrets.randbelow(1000) + 1)                 # 1 to 1000

random.seed(42)                                    # same seed, same sequence
print(random.randint(1, 100))

When all you need is a list to paste into a spreadsheet or a test file, the generator on this page produces it without a script.

Frequently asked questions

Are both Min and Max included?
Yes. With Min -3 and Max 3 the generator can return any of the seven integers from -3 to 3, each with a probability of one in seven.
What happens if I type a decimal bound?
Min is rounded up and Max is rounded down to the nearest integer, so 1.5 to 6.5 behaves like 2 to 6. If no whole number lies between the bounds, you get an error instead.
Why did the same integer come up twice?
Without Unique values every draw is independent, and repeats are normal, especially in small ranges. Tick Unique values if each integer may appear only once.
How does this differ from the Random Number Generator?
The engine is the same. This page starts with a signed range and explains integer behaviour for test data and sampling; the Random Number Generator starts at 1 to 100 for everyday picks.
Can it produce 64-bit integers?
Not across the full 64-bit range. Values should stay within plus or minus 9,007,199,254,740,991, the largest integers JavaScript stores exactly, and Max minus Min cannot exceed that number.

Last updated October 3, 2026

Related tools