By Tim King · Updated
Random PIN Generator
Skips Repeated and Sequential Patterns, With the Odds of a Guess Shown
OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.
How the Random PIN Generator works
This random PIN generator avoids the PINs everyone guesses. Choose four, six or eight digits and the generator draws a PIN from your browser's cryptographic random source, rejecting the handful of codes that every attacker tries first: a single repeated digit such as 0000, and straight runs such as 1234 or 8765. The stats show how many codes are possible and the chance of one guess. Generated locally, never sent anywhere.
Random PIN generator: why 1234 is the problem
A four-digit PIN has 10,000 possibilities, which sounds small and is, but the real weakness is not the length. It is that people do not choose from all 10,000. An analysis of 3.4 million leaked four-digit PINs found that 1234 alone accounted for almost 11% of them, the top twenty covered more than a quarter, and years of birth from 1950 to 2000 filled most of the rest of the top few hundred. An attacker with three guesses before lockout who tries 1234, 1111 and 0000 gets into nearly one in five accounts. A random PIN moves you out of that group entirely.
What the generator refuses to produce
Each digit is drawn independently from 0 to 9, so every code is equally likely to start with. Two families of results are then thrown away and redrawn: codes made of a single repeated digit, and straight ascending or descending runs including 0123 and 9876. Those are the codes at the top of every guess list, and rejecting them costs almost nothing in the total space — 24 of 10,000 four-digit codes — while removing the one case where a random draw would hand you a code an attacker tries in the first minute.
| Digits | Possible codes | Chance of one guess | Guesses to try half |
|---|---|---|---|
| 4 | 10,000 | 1 in 10,000 | 5,000 |
| 6 | 1,000,000 | 1 in 1,000,000 | 500,000 |
| 8 | 100,000,000 | 1 in 100,000,000 | 50,000,000 |
Four, six or eight digits
Four digits is what most bank cards and older phones allow, and it relies entirely on the lockout: three wrong attempts and the card is swallowed, ten and the phone wipes. Under that rule a random four-digit PIN is fine, because the attacker's odds are three in ten thousand. Six digits is the current phone default and the right choice wherever it is offered, since 1,000,000 codes makes even a patient attacker with a slow brute-force rig wait days. Eight is for systems that let you choose and where the code protects something valuable. None of them is a substitute for a password where a password is allowed: a PIN is only safe when something limits the guesses.
Where a PIN is the wrong tool
A PIN protects a device or card that an attacker must physically hold and that locks after a few tries. It does not protect an online account, where guesses are free and fast, and it should never be the same code across your phone, bank card and door. Use a different random code for each, and if a service offers a longer password or a passkey instead, take it.
Generated locally, never sent
The digits come from crypto.getRandomValues in your browser. No request is made when you
generate, nothing is logged, and the codes exist only on this page until you copy them. Reload
and they are gone.
FAQ
What are the most common PIN numbers?
1234 by a wide margin, then 1111, 0000, 1212, 7777, 1004, 2000, 4444, 2222 and 6969, according to the largest published analysis of leaked PINs. Years of birth and simple keypad shapes such as 2580 make up most of the rest of the top hundred, which is why a random draw is safer than anything you would think of.
Is a random 4 digit PIN secure?
Against an attacker who has your card or phone and a limited number of tries, yes: three guesses out of ten thousand is a 0.03% chance. It is not secure against unlimited guessing, so it only works where the device locks. Choose six digits wherever the system allows it.
Why does the generator reject some codes?
Because repeated digits and straight runs are the first codes any attacker tries, and a random draw will occasionally produce one. Removing them drops 24 codes from 10,000 possibilities, which is invisible in the odds, and guarantees the result is never one of the top guesses.
Can I use my birth year or phone number instead?
Better not. Years from 1940 to 2010 and dates in DDMM or MMDD form are the largest block of commonly used PINs after 1234 and repeated digits, and anyone who knows a little about you can guess them. A random code takes seconds to memorise after a few uses.
Is the PIN sent to a server?
No. Generation happens in your browser using the same cryptographic random source the operating system uses, with no network request. The page works with the connection turned off, which is the easiest way to confirm it for yourself.
See also: all Security & Identifiers tools, Dev Utilities, Formatters & Validators, Data & Encoding, SEO, Accessibility, AI.
Related tools
Passphrase Generator
Diceware passphrases from the EFF wordlist, generated locally.
Memorable Password Generator
Random words, a symbol and digits — strong, and you can remember it.
WiFi Password Generator
WPA2/WPA3 keys with no look-alike characters, easy to read aloud.
UUID Generator
Random v4 or time-ordered v7 UUIDs, generated in your browser.
AES Key Generator
Random AES-128, 192 or 256-bit keys in hex, Base64 or JWK.