PIN & OTP Generator
Generate secure random PINs, OTPs, and numeric codes of any length. Useful for testing authentication flows, generating temporary passwords, and creating access codes.
Did this tool work for you?
How to use this calculator
Each digit is drawn independently from the browser’s cryptographic random source; bytes of 250 or more are discarded so every digit is equally likely. The optional filters redraw a code when it is all one digit, or when every neighbouring pair of digits differs by 0 or 1.
- 1
Set the code length (4–12 digits) and how many codes to generate.
- 2
Enable "avoid sequential" to skip codes like 1234 or 4567.
- 3
Enable "avoid all-same" to skip codes like 0000 or 1111 (on by default).
Frequently asked questions
Is the PIN generated with a cryptographically secure source?
Yes. Each digit comes from crypto.getRandomValues, the browser’s cryptographic random source, not from Math.random. To keep all ten digits equally likely the code throws away any random byte of 250 or higher and uses the remainder of the rest divided by 10. If the browser has no such source, the tool shows an error instead of quietly using a weaker one.
What lengths and quantities are allowed?
Length is clamped to 4–12 digits and the quantity to 1–10 codes. Typing 2 for length gives 4 digits, typing 20 gives 12. An empty or non-numeric field falls back to the defaults of 6 digits and 5 codes.
What exactly do the two filters remove?
"Avoid all-same digits" (on by default) rejects codes such as 0000 or 777777. "Avoid sequential digits" is wider than the name suggests: it rejects any code in which every neighbouring pair of digits differs by 0 or 1, so 1234, 4321, 1212, 3454 and 1121 are all redrawn. Each filter retries up to 1000 times, which is far more than needed for lengths of 4 or more.
Can a code start with 0?
Yes. Digits are drawn independently, so leading zeros are normal; one sample run produced 040 963. Keep codes as text rather than numbers in spreadsheets or databases, or the zero will be dropped.
What do the Entropy and combinations lines mean?
They are length × log2(10) bits and 10 to the power of the length. A 6-digit code is 19.9 bits, or 1,000,000 combinations. The figures ignore the filters, which remove a small share of possibilities, so the true number is slightly lower when they are on.
Is this an OTP generator in the TOTP or HOTP sense?
No. It produces random digit strings and nothing else. It does not keep a secret key, apply a time window or counter (the HOTP and TOTP schemes of RFC 4226 and RFC 6238), store codes, expire them or check them against anything. Use it to make test fixtures, one-off access codes or placeholder PINs, and let your authentication system do the verification.
How do the Grouped and Dashed formats split a code?
They split at floor(length ÷ 2). A 6-digit code becomes 3+3 (040 963), and a 7-digit code becomes 3+4 (338-5993). The separator is cosmetic: remove it before storing or comparing the code.
PIN codes from a cryptographic random source
How each digit is chosen
The generator asks the browser for one random byte at a time with crypto.getRandomValues. A byte holds 256 values, which does not divide evenly by 10, so bytes from 250 to 255 are discarded and drawn again. The remaining 250 values map to digits by taking the remainder after dividing by 10, giving each digit exactly 25 byte values and removing modulo bias. A code is simply that many independent digits joined together, and the whole calculation runs in the page, with no network request in the code.
Length against guessing space
Every extra digit multiplies the number of possible codes by ten. The entropy line in the results is the number of bits of uncertainty in a code before any filter is applied. How long a guess campaign would take depends entirely on the system checking the PIN, such as lockouts and rate limits, so the table shows only the size of the space.
| Digits | Combinations | Entropy |
|---|---|---|
| 4 | 10,000 | 13.3 bits |
| 6 | 1,000,000 | 19.9 bits |
| 8 | 100,000,000 | 26.6 bits |
| 12 | 1,000,000,000,000 | 39.9 bits |
Worked example: formats
A run with length 6, two codes and the Grouped format returned 040 963 and 999 601 along with the entropy line of 19.9 bits and the combinations line of 10^6 = 1,000,000. The second code shows what the default filter permits: only an all-same code such as 999999 is rejected, so 999 601 passes. A run with length 7 and Dashed format produced 338-5993, a 3+4 split. These values are samples; every click draws new digits, so you will not get the same ones.
Filters in practice
Switching on "Avoid sequential digits" removes more than staircases. Because the test is that no neighbouring pair differs by more than one, it also removes 1212, 5454 and 2111. For a 4-digit code this rejects about 2.3% of random draws (230 of the 10,000 codes), and for 6 digits under 0.2%, so the retry loop is cheap. Both filters redraw the whole code rather than patching a digit, which keeps the surviving codes uniformly distributed among those allowed.
Limits worth knowing
Generating a PIN does not make it safe to use. Anything you copy ends up on your clipboard and in whatever you paste it into, and the tool cannot enforce lockouts or expiry. It also does not implement one-time-password standards; it only creates random digit strings. For a code that must be confirmed by a server, generate and check it on that server, and treat this page as a source of test values and one-off access codes.
Learn more from an authoritative source:
WikipediaName Generator
Generate random names for babies, characters, businesses, or projects. Choose from real names by origin or creative fantasy/sci-fi name styles.
Hash Generator
Generate MD5, SHA-1, and SHA-256 style hashes from any text input. Useful for checksums, data integrity verification, and learning about hashing.
Random Quote Generator
Get an inspiring, funny, or wise random quote from famous thinkers, leaders, and entertainers. Filter by category.
Story Plot Generator
Generate a unique story plot with character, setting, conflict, and twist for any genre — great for writers, RPGs, and creative exercises.
Character Name Generator
Generate unique character names for fantasy, sci-fi, historical fiction, or modern stories. Choose gender, origin, and style.
Mad Libs Generator
Fill in funny words to create a hilarious Mad Libs story. Choose from adventure, job interview, mystery, and holiday disaster templates.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →