Generators
How to Generate Random Numbers
Every tool and programming language has its own way to generate random numbers. Here are all the methods — from a browser tool to Excel, Python, and beyond.
Methods by platform
Choosing the right method
For one-off picks (raffle winner, game decision, random choice): an online tool is fastest — no code, no setup, works on any device.
For spreadsheets with random data: RANDBETWEEN in Excel or Google Sheets is the natural choice and recalculates automatically.
For programming: use your language's built-in random library. For anything security-related (tokens, passwords), use the cryptographically secure version — Python's secrets module or JavaScript's crypto.getRandomValues().
Generate random numbers instantly — no setup
Set your range, pick a count, enable no-duplicates if needed. Free, instant.
Random Number Generator →Frequently asked questions
How do I generate a random number in Excel?
Use =RANDBETWEEN(1,100) to generate a random whole number between 1 and 100. Change the values for a different range. The function recalculates every time the spreadsheet changes — press F9 to force a refresh. For a random decimal between 0 and 1, use =RAND(). To prevent the number from changing, copy the cell and paste as 'Values only'.
How do I generate a random number in Python?
Import the random module and use random.randint(1, 100) for a random integer between 1 and 100 (inclusive). For a list of unique random numbers, use random.sample(range(1, 101), k=5) to get 5 unique numbers. For cryptographically secure random numbers, use the secrets module: secrets.randbelow(100) + 1.
How do I generate a random number in Google Sheets?
Google Sheets supports the same functions as Excel: =RANDBETWEEN(1,100) for a random integer and =RAND() for a random decimal. The function recalculates automatically when the sheet refreshes. To keep the number fixed, copy it and use Edit > Paste Special > Values Only.
What is the difference between random and pseudorandom numbers?
True random numbers are generated from physical processes that are genuinely unpredictable (radioactive decay, atmospheric noise). Pseudorandom numbers are generated by a deterministic mathematical algorithm seeded with an initial value — they appear random and pass statistical tests, but are technically reproducible if you know the seed. For most purposes (games, simulations, random draws) pseudorandom is indistinguishable from true random. For cryptography, you need cryptographically secure pseudorandom number generators (CSPRNG).
How do I generate random numbers without repeats?
For a set of unique random numbers: in Excel, use =RANK(RAND(), range) across a list. In Python, use random.sample(). In an online tool, enable the 'No Duplicates' option. This ensures each number appears only once in your results, which is required for lottery picks, raffle draws, and any situation where repeats would be unfair.
Can I generate a truly random number online?
Browser-based tools use Math.random() or crypto.getRandomValues(). The latter uses the operating system's entropy pool (which includes timing of hardware events, mouse movements, etc.) and is considered cryptographically secure — suitable even for security applications. Math.random() is pseudorandom but statistically uniform, which is sufficient for games, simulations, and general-purpose random picks.