piapia123
en

Random Number Generator

Generators

Everything runs locally in your browser — nothing is uploaded

Output

Generating a random number looks like the simplest thing in the world, and whether it comes out right depends entirely on a few easily missed details. The random source is `crypto.getRandomValues`, not `Math.random`. The latter is a predictable pseudo-random sequence in some engines, which is a genuine hole when the numbers are used for draws, vouchers or random grouping. Ranges are inclusive. Ask for 1 to 10 and both 1 and 10 are reachable. The implementation uses rejection sampling rather than a modulo, which would make the lower values slightly more likely (mapping 0–255 onto 1–10 gives six sources for the first six values and five for the rest). The skew is invisible in small samples, but it is a real skew. Deduplication is a promise. Tick it and ask for more values than the range holds, and you get an error — never a quiet shortfall or a quiet duplicate. Bases are a column, not another tool. “Ten random binary numbers” and “ten random numbers, then to binary” are the same job, done in one place here.

Features

  • Integers or decimals, with both ends of the range reachable
  • The random source is `crypto.getRandomValues`, not a predictable pseudo-random sequence
  • Rejection sampling keeps the distribution uniform — no bias towards the low end
  • Optional deduplication that errors out rather than quietly repeating or shortchanging you
  • Sort ascending or descending; the same batch is sorted, not regenerated
  • Output as decimal, binary (0b), octal (0o) or hex (0x)
  • Up to 1000 values at a time, with integers covering ±2⁵³
  • Zero to twelve decimal places
  • Everything is generated on your machine with no requests

How to use

  1. Choose integers or decimals
  2. Fill in the minimum, maximum and how many you want
  3. Tick deduplication or pick a sort order if you need them
  4. Click Generate again for a new batch, then Copy

FAQ

Why not use Math.random?
Because `Math.random` is a predictable pseudo-random sequence in some engines — after enough outputs, the next value can be worked out. Using it for draws, coupon codes or random grouping hands the result to anyone who can see the sequence. This tool uses `crypto.getRandomValues`, the cryptographically secure source provided by the operating system, whose internal state is never exposed.
Why does “no duplicates” raise an error instead of just giving fewer values?
Because it is a promise. Ask for ten distinct values and receive seven, and you will think the tool is broken or that you miscounted; receive ten with a repeat inside and you will think deduplication silently failed. Both are worse than an error, and the error even tells you how many distinct values the range actually holds.
Is the output really uniform?
Both halves of that were handled. The source is cryptographic (see above). The mapping uses rejection sampling: it computes the largest multiple of the range that fits the drawn bits and discards anything past it. The common `randomByte % range` shortcut makes the lower values slightly more likely (0–255 modulo 1–10 gives six sources for the first six values and five for the rest) — a small but real bias, and exactly the kind that matters for a draw.

Related tools