All tools
Integer sampling

Random Number Generator

Draw integers from an inclusive range for classroom activities and casual sampling. Allow repetitions or choose unique values, then sort and export the same stored draw without secretly rerandomizing it.

Settings and generated numbers stay in browser memory. Refreshing clears results and Undo; nothing is saved or added to URLs.

Choose your integer range

Inclusive bounds: -10^18 through +10^18. Quantity: 1-10,000. Signed decimal integers only; up to 128 characters per field. Surrounding whitespace is allowed; grouping, decimals and exponents are not.

Without repetition, quantity must fit the exact range size. With repetition, a fresh draw may produce the same number or batch; no secret rerolls are performed.

Order and separator reformat the stored draw. Only Generate or Generate again requests new random values.

Your sampled integers

Choose settings and generate a batch. Editing a bound, quantity or repeat policy hides the old draw until you generate again or Undo.

How to generate random integers

  1. Choose Minimum and Maximum. Both endpoints are included; bounds can be negative, zero or positive.
  2. Enter a quantity from 1 to 10,000. Turn off Allow repeated values for a draw without replacement; the quantity must fit the exact range size.
  3. Generate a batch. Generate again requests a fresh draw, which may legitimately repeat an earlier number or batch. Undo generation restores the preceding batch and its settings without drawing again.
  4. Choose Draw order, Ascending or Descending, and Newline, Comma-space or Space. These controls only reformat the stored values.
  5. Copy or download the full batch as random-numbers.txt. Reset restores defaults and clears output, with one-step Undo.

Worked example: five unique integers from -2 through 2

The inclusive range size is 2 - (-2) + 1 = 5. With repetitions off and quantity 5, the result contains -2, -1, 0, 1 and 2 exactly once, in sampled order. A possible draw is 1, -2, 2, 0, -1; this example is not a predicted sequence. Ascending display shows -2, -1, 0, 1, 2 without changing the draw.

For a one-value range such as 7 through 7, quantity 3 with repetitions gives 7, 7, 7. Without repetitions only quantity 1 is valid. Reversed endpoints are rejected rather than automatically swapped.

Exact values, inclusive bounds and input rules

Bounds run from -1,000,000,000,000,000,000 through +1,000,000,000,000,000,000. BigInt is used for parsing, range sizes, sample offsets, uniqueness, comparisons and decimal output. Values above JavaScript's safe Number precision, such as 9007199254740992 through 9007199254740994, remain exact.

Use ASCII decimal digits with an optional + or - sign and surrounding whitespace. Leading zeroes are accepted; grouping, decimal points, exponents, hexadecimal prefixes, NaN and trailing text are rejected. Each field is limited to 128 characters to keep validation bounded. Empty fields remain incomplete, not zero. Quantity is a positive integer from 1 through 10,000.

How unbiased sampling and uniqueness work

The browser's crypto.getRandomValues supplies random 32-bit words. For an offset bound n, the generator uses enough bits to represent n - 1, masks unused high bits and rejects candidates at or above n. It consumes new entropy after rejection, rather than reducing a biased candidate modulo n. When n is 1 the offset is zero directly.

Repeated-value draws sample independently. Unique draws use a sparse-map partial Fisher-Yates algorithm over virtual offsets: select a remaining position uniformly, take its value, replace that position with the last remaining value and shrink the range. This uses memory proportional to the quantity, not the potentially enormous range, and does not repeatedly retry duplicates near saturation.

Sorting uses exact BigInt comparisons and keeps the original sampled order available. There is no Math.random fallback, floating-point probability multiplication, user-supplied seed or hidden reroll to force visibly different results. Secure-randomness failure is reported explicitly.

Large batches, cancellation, exports and privacy

Sampling is limited to 10,000 values and runs in a local cancellable worker. Editing draw settings cancels obsolete work and hides mismatched results. Output preview shows at most 1,000 values with an explicit notice; Copy, UTF-8 TXT download and the complete selectable output include the entire batch.

Clipboard failure opens the selectable full output for manual copying. Object URLs and workers are released when replaced or finished. Previous batches and one-step Undo are memory-only; no settings or sequence are stored across refresh, uploaded, logged, sent to analytics or placed in the URL.

What this generator is not for

This tool is for casual integer sampling and classroom use, not audited or certified draws. It does not provide decimals, weighted probabilities, shared seeds, lottery or prize management, audit certificates or security credentials. A strong entropy source does not make this interface a password generator; use the dedicated password tool for that task.