PIN Code Generator
Published Updated
Generate a random PIN of 3 to 12 digits, with preset buttons for 4 and 6. Digits are drawn from the browser's crypto source with rejection sampling, so 0000 is exactly as likely as 7316, and a leading zero turns up 10% of the time.
What each length buys
The last column assumes a guesser who tries 100 different PINs. NIST SP 800-63B says a verifier must limit an account to no more than 100 consecutive failed attempts, and that a randomly assigned secret must be at least 6 characters, entirely numeric if need be.
| Digits | Combinations | Entropy | Chance in 100 tries |
|---|---|---|---|
| 3 | 1,000 | 10.0 bits | 10% |
| 4 | 10,000 | 13.3 bits | 1% |
| 6 | 1,000,000 | 19.9 bits | 0.01% |
| 8 | 100,000,000 | 26.6 bits | 0.0001% |
| 12 | 1,000,000,000,000 | 39.9 bits | 1 in 10 billion |
How a digit is chosen
One crypto byte can be 0 to 255. Taking it modulo 10 would favour 0 to 5, which appear 26 times each against 25 for the others, so the page discards bytes of 250 or more and tries again. That wastes 2.3% of the bytes.
In 200,000 four-digit PINs, all 10,000 possible values appeared, every digit's share fell between 9.94% and 10.06%, and 50.3% of the PINs had four different digits, against the 50.4% that chance predicts.
Making a PIN
Step 1
Pick a length
Press 4 or 6, or type a number from 3 to 12. A number outside that range is ignored, and the PIN keeps its previous length.
Step 2
Press the refresh icon
A new PIN appears on every length change and every press. The previous one is not kept anywhere.
Step 3
Copy the PIN
Copy puts the digits on the clipboard. Memorise it or store it somewhere safe before you leave, because the page keeps no history.
Limits of a generated PIN
- It is random, so it ignores birthdays and patterns, which is its main advantage over a chosen PIN.
- It does not know your lock's rules, which may fix the length or reject repeated or sequential digits.
- For a longer secret, Password Generator and Passphrase Generator offer more bits per entry.
PIN questions
Why does my PIN start with a zero?
Each digit is drawn independently, so 10% of PINs begin with 0. Copy keeps the zero, but a spreadsheet or phone field that treats the PIN as a number may drop it.
Are 0000 and 1234 possible?
Yes, each with the same 1 in 10,000 chance as any other 4-digit PIN. In 200,000 test PINs, 0.1% had four identical digits. Press refresh again if a lock rejects the result.
Is 4 digits enough?
Only where the system limits guessing. There are 10,000 combinations, and 13.3 bits of entropy. Six digits give 1,000,000, and NIST treats random 6-digit PINs as adequate when attempts are limited.
What does rejection sampling mean here?
One random byte has 256 values, which does not divide evenly by 10. Bytes from 250 to 255 are thrown away and redrawn, so every digit keeps an equal chance.
Can I generate several PINs at once?
No. The page makes one PIN per press. Press refresh and copy each one in turn.
Does the PIN leave my device?
No. It is built in the page from crypto.getRandomValues and shown on screen. Nothing is sent or stored, and reloading the page produces a different PIN.