Generate a cryptographically secure PIN in one click. Set your length, block repeated digits or sequential runs, and generate up to ten at a time — everything runs in your browser and is never transmitted anywhere.
Press Enter or Space to refresh
Password generators, passphrase tools, and more — all free
A PIN, or Personal Identification Number, is a short numeric code, typically between 4 and 8 digits long and consisting only of numbers, used to verify the identity of the user. It is found on a locked mobile phone, the front of bank cards at cashpoints, hotel room safe keypads, voicemail systems, and many other sites. The main difference between a PIN and a password is that a PIN is shorter and consists only of numbers.
The problem is that people don't select PINs randomly. In the majority of cases, the PIN chosen by the user is a number that is easy for them to remember. For most attackers using guess lists, the same numbers appear at the top again and again. The result of leaked PIN databases, time and time again, is the same short list of numbers: 1234, 0000, 1111, 1212, 7777. Over 10% of all leaked PINs are one of these 5 numbers. In choosing your own PIN, you may inadvertently select a number that appears on every such list.
A random PIN generator removes the human bias completely. This tool generates PINs using crypto.getRandomValues(), the browser's cryptographically secure random number source, the same one used to establish HTTPS connections. It runs entirely in your browser. Nothing you generate here is transmitted to any server, stored in any database, or logged anywhere.
In reality, humans are not good at choosing random numbers, and the consequences of choosing a guessable smart card PIN can be severe. Even when choosing a PIN yourself, the scope of possible numbers is much smaller than you would expect. While most people try to avoid well-known "bad" PIN numbers such as 0000 or 1234, they often choose numbers that seem to be chosen randomly but in reality are not. This can include previous phone numbers, parts of addresses (such as the last four digits), and years of birth or significance. Such numbers form patterns that are cataloged by specialist PIN crackers who maintain lists of tens of thousands of "popular" PINs in order of prevalence from databases of security breaches. It is probably easier for you to come up with a 'good' random 4-digit number than most people would come up with a number that thousands of other people would also come up with. For a randomly chosen 4-digit PIN, there are 10,000 possible PINs, all equally likely. Most systems will enforce a 3-attempt lockout policy, similar to that used for ATM cards or for trying to unlock an iPhone. So even if an attacker knows how many digits your PIN has, it's highly unlikely that they'll be able to guess your PIN before getting locked out. A 6-digit PIN gives an attacker 1,000,000 possible PINs to search through, while an 8-digit PIN gives 100 million possible PINs. Each additional digit adds a further ten to the search space.
Choosing a PIN yourself restricts you to a much smaller biased set of values rather than letting you choose from the full 10,000 possible PINs. A PIN generator chooses a completely random PIN every time it is run.
This tool uses window.crypto.getRandomValues(), the Web Cryptography API, to generate random numbers. Math.random() (which is used elsewhere in this project) is a pseudo-random number generator. The numbers it generates are typically sufficient for non-security-related tasks that require randomness, but they can be predicted by a determined attacker who knows the algorithm and seed used to generate them. crypto.getRandomValues(), on the other hand, generates numbers from the operating system's entropy pool. This can include a wide variety of things, including random hardware events, timing differences, etc. All of these are essentially unpredictable.
For a standard PIN, we use rejection sampling: we generate random bytes, map them to digits 0–9, and throw away bytes with values that have a statistical bias (in 8-bit bytes that are greater than or equal to 250 (0.fn)).
For no-repeat mode, the tool creates a list of all digits (0 to 9) and shuffles it using a Fisher-Yates shuffle. The first N digits of the shuffled list are then used to generate the key. For this purpose, all possible combinations of N digits (all digits being distinct) are generated with the same probability as a corresponding randomly generated key of that length. The check for three or more ascending or descending digits like 1-2-3 or 5-6-7 or 9-8-7 takes less than a millisecond for all supported key lengths and is therefore performed in the normal loop without any delay.
Use a different PIN for each account. Using one PIN for your phone, bank card, building, and home safe is too much to bear if one context is compromised. It takes seconds to generate, and it's best to store them in a password manager, there's no good reason to reuse a PIN.
Use the longest PIN supported by the system. Most people default to 4-digit PINs because 4 is the minimum number of digits allowed. 6-digit PINs (1 million combinations) are stronger than 4-digit PINs (10,000 combinations). 8-digit PINs grant 100 million combinations. For something like a safe or a device that contains very sensitive information or valuable documents, use the longest possible PIN.
The PIN should never be written near the card it is for or the device into which it is entered. Store it in a password manager if you don't mind paying a monthly fee. You could store it in a secure notepad or Excel sheet that only you can access. However, storing the PIN on a sticky note in your wallet or on the back of a keypad defeats the purpose of a PIN.
Do not use a PIN where a password is possible. A 4-digit PIN has a maximum of 10,000 possible values. In contrast, a 16-character password containing letters, numbers and symbols has trillions of possible values. Therefore, use a full password for online accounts wherever possible. PINs are used for things such as ATMs, mobile phones and safe locks. In these cases, a hardware-enforced lockout period can be put in place to compensate for the PIN being too short.
The same logic applies to your passwords and your PINs. There's no way to remember dozens of completely random numbers and get them all right most of the time without some help.
Password manager. Your password manager can store any amount of text, including notes and even custom fields. Thus, you can store the generated PINs in the Password Manager entry for "Phone PIN" or "ATM card PIN" (or any other name that you find suitable). Your password manager is protected with your master password, a simple-to-remember passphrase.
For frequently used PINs (e.g., your phone lock code, primary bank card), it is actually worthwhile memorizing them. Generate a random PIN above and enter it 20-30 times over a period of 2-3 days. After a while, entering PINs will be almost second nature. After that, you can delete the PIN from your temporary storage.
There are a few instances in which you should change your PIN. First, if you suspect that someone knows your PIN, for example, by shoulder surfing, then you should change it. Also, if the system indicates that there have been failed unlock attempts, then you should change your PIN. Lastly, if someone who knows your PIN is no longer supposed to use it, change your PIN. Changing a PIN on a fixed schedule, such as every 90 days, has fallen out of favor and is no longer included in most security policies, including NIST.