Random Numbers Generator
Generate random numbers in a range. Integer or decimal, with optional uniqueness constraint.
About Random Numbers Generator
Generate N random numbers within a configurable range. Pick integer or floating-point output, choose how many decimal places to keep, and optionally enforce that all values are unique. Uses Math.random — fine for most testing and prototyping, but not cryptographically secure (use random-string for that).
When to use it
- Filling test fixtures with sample data
- Generating dummy IDs or coordinates
- Producing test inputs for a numeric algorithm
- Picking random samples within a range
How it works
Each number is drawn as `Math.random() * (max - min) + min`. Integer mode floors the result; decimal mode rounds to the configured number of places. The unique mode tracks seen values in a Set and re-draws collisions. The integer unique mode validates that the requested count fits in the range to avoid infinite loops.
Examples
Count=5, min=1, max=10, integer, unique
7 2 9 4 6
Frequently asked questions
- Is the randomness cryptographically secure?
- No. Math.random is sufficient for testing, simulation, and games but not for security-sensitive use. For secure random output, use the random-string tool, which uses crypto.getRandomValues.
- What happens if I request too many unique integers?
- An error appears. For example, you can't generate 100 unique integers from the range 1–10. Widen the range or disable the unique constraint.
- Are the bounds inclusive?
- Both min and max are inclusive for integer mode. For decimal mode, max is exclusive in theory (Math.random can equal exactly 0 but not 1), but with rounding the difference is negligible.