Backup codes are one-time codes you create in advance, while you can still sign in, so you can get back into an account when your normal second factor is unavailable. Google gives you ten 8-digit codes, Microsoft gives one 25-character recovery code, and GitHub gives sixteen codes. Each code works once, and creating a new set makes the old set stop working.
Key takeaways
- Backup codes are single-use spare keys for two-factor authentication, created in advance while you can still sign in.
- Google gives ten 8-digit codes, Microsoft gives one 25-character recovery code, and GitHub gives sixteen codes.
- Print them and keep them offline, away from the phone you sign in with, and make a new set if a copy is lost.
Two-factor authentication protects your account, but it also ties sign-in to your phone. If that phone is lost, broken or replaced, the same protection can lock you out of your own account.
What are backup codes?
Backup codes are one-time codes you create in advance, while you can still sign in, so you can get back into an account when your normal second factor is unavailable. Each code works once, then it stops working.
Think of them as a spare key. Your password is the front-door key, and your authenticator app or text code is the second lock. A backup code opens that second lock when the usual key is gone.
Services use different names for the same idea. Google calls them backup codes, Microsoft and GitHub call them recovery codes, and Apple offers a recovery key instead. The job is the same in every case: prove it is you when the normal route fails.
You can only create backup codes while you have access. Once you are locked out, you cannot generate a new set. That timing is the whole point of this article, so make them today, not after a problem.
How do backup codes work?
When you turn on two-factor authentication, signing in needs your password plus a second factor, such as a code from an authenticator app, a passkey or a text message. A backup code stands in for that second factor.
At the sign-in screen, you choose the option to try another way, then enter one unused backup code. The service accepts it once and marks it as used. The next time you need one, you use a different code from the set.
Because each code works only once, a stolen code is less useful than a stolen password. An attacker who finds one code can use it a single time, and only if they also know your password.
Creating a new set usually cancels the old one. Google says that when you create a new set of ten codes, the old set automatically becomes inactive. Microsoft says the same for its single recovery code.
What do backup codes look like for each service?
Every service formats its codes differently, so do not expect the same set everywhere. The table below summarizes the details from each company's help pages.
| Service | What you get | Where to find it | Key rule |
|---|---|---|---|
| 10 codes, 8 digits each | Google Account, Security and sign-in, 2-Step Verification, Backup codes | Each code works once; a new set cancels the old one | |
| Microsoft | One 25-character recovery code | Microsoft account security, Manage how I sign in, Recovery code | An old code cannot be shown again; a new code cancels it |
| GitHub | 16 recovery codes | Settings, Password and authentication, Recovery codes | Each code works once; a new set cancels the old one |
| Apple | Optional 28-character recovery key | iPhone Settings, your name, Sign-In and Security, Account Recovery | No backup codes; Apple cannot replace a lost key |
| Discord | A set of single-use backup codes | User Settings, My Account, View Backup Codes | Use one in place of the authenticator code at sign-in |
| A set of recovery codes | Accounts Center, Password and security, Two-factor authentication | Use one when your usual second factor is unavailable |
Apple is the exception worth noting. It does not offer backup codes at all. Its optional recovery key is 28 characters long, and if you lose both the key and access to your trusted devices, Apple cannot give you a new copy.
For a wider look at account protection, see our guide to how to know if your phone is hacked, since a lost or compromised phone is the most common reason people need these codes.
How do you get Google backup codes?
Google gives you ten 8-digit backup codes, and you need 2-Step Verification turned on to use them. After you use a code to sign in, that code becomes inactive.
To create them, open your Google Account, go to Security and sign-in, then 2-Step Verification, then Backup codes. From there you can print or download the set. Google suggests storing the printed copy where you keep your passport or other important documents.
If you downloaded the file, search your computer for a file named like Backup-codes-yourusername.txt if you lose track of it. Google also warns that you cannot download backup codes if you are in the Advanced Protection Program.
To use one, sign in as normal, choose "Try another way", then "Enter one of your 8-digit backup codes", and type an unused code. Google says it never asks for a backup code other than at sign in, so treat any other request as a scam.
Full steps are on Google Account Help. Note that the link above uses the clean help-page address; the version in our sources list is the exact page we opened.
How do you get a Microsoft recovery code?
Microsoft gives you one 25-character recovery code, not a set. It helps you regain access if you forget your password or if your account is compromised.
To generate it, go to the Manage how I sign in page of your Microsoft account security dashboard, scroll to the Recovery code section, and select Generate a new code, as Microsoft Support explains. Microsoft advises printing the code and keeping it in a safe place.
You cannot view or download a code you already generated. If you can sign in, you can create a new one at any time, but that new code makes the previous one stop working. Microsoft also advises against storing it on a device you use to sign in to the account.
To use it, start signing in, choose the other ways to sign in, then follow the prompts until you reach "Do you have an account recovery code?" and enter the code. Recovery codes are not case-sensitive, and spaces and dashes do not matter.
If two-step verification is on, Microsoft notes that you must wait 30 days for some changes to take effect. That delay is another reason to create the code now, while everything works.
What about GitHub, Apple and other services?
GitHub gives you sixteen recovery codes in Settings, under Password and authentication. Each code works once, and generating a new set invalidates the old codes. You can download, print or copy them from that page.
Apple's recovery key is different. You turn it on in iPhone Settings, under your name, Sign-In and Security, then Account Recovery. It replaces Apple's standard account recovery, so losing it can mean losing the account for good. Only turn it on if you have a safe place to store it.
Discord shows its backup codes in User Settings, under My Account, where you can view or download them. Facebook keeps its recovery codes in Accounts Center, under Password and security and then Two-factor authentication.
The pattern is the same everywhere: look in security settings, near the two-factor authentication controls, for words like backup codes, recovery codes or recovery key. If a service offers no such option, add a second trusted device or a passkey instead.
Where should you store backup codes?
Print them and keep the paper offline, away from the phone you sign in with. A printed sheet in a safe place works when your phone is broken, your number has been reassigned, or your authenticator app was not backed up.
Good storage is boring on purpose. Keep the printout with your passport or other important papers, in a locked drawer, or in a safe. If you keep a copy in a password manager, make sure that manager itself has its own backup codes stored separately.
Bad storage defeats the point. Do not keep your only copy in a photo on the same phone, in an email account protected by the same codes, or in a note that syncs to a device you could lose at the same time.
Never share a backup code with anyone. Google states plainly that it never asks for passwords or verification codes over email, phone or message. Microsoft says its agents are not allowed to send password reset links or change account details.
What should you do if you lose your phone?
First, use a backup code to sign in from a trusted computer. Then, once you are in, remove the lost phone from your trusted devices and set up your authenticator app or passkey on the replacement phone.
Next, create a fresh set of backup codes. Remember that a new set cancels the old one, so replace the printed copy too. If you used a Microsoft recovery code, generate a new one after you regain access.
Check for signs of misuse while you are in the account. Look at recent sign-ins, connected devices, recovery email and phone numbers, and any new forwarding rules. Change your password if anything looks wrong.
If you have no backup codes, use the service's account recovery process. Google suggests answering every question, even if you have to guess, and recovering from a device and place you usually sign in from. Microsoft offers a sign-in helper on its website.
What mistakes do people make with backup codes?
The most common mistake is never creating them at all. Many people turn on two-factor authentication, feel safe, and only discover the gap when the phone is gone.
The second mistake is storing the only copy on the same phone. A screenshot in the camera roll does not help when the phone is stolen or wiped.
The third mistake is sharing a code with someone who asks for it. No real support agent, bank or service will ask for your backup code in a chat, call or email. Anyone who does is trying to take over your account.
The fourth mistake is forgetting that a new set cancels the old one. If you refresh your codes and throw away the printout without replacing it, you may have no working set left.
If a password you use was ever exposed in a breach, check it with our pwned password checker and change it before you rely on backup codes alone.
The bottom line
Backup codes are a small piece of paper that can save an account. They cost ten minutes to create, they work when your phone does not, and they only help if you make them before you need them.
Create a set for each important account, print it, store it offline, and replace it whenever you use a code or suspect a copy is lost. You can start by checking the strength of the passwords those codes protect with our free password strength checker.
Frequently asked questions
What are backup codes used for?
Backup codes let you sign in when your normal second factor is unavailable, for example if you lose your phone, change your number, or your authenticator app is not backed up. You type one unused code instead of the usual authenticator or text code.
How many backup codes does Google give you?
Google gives you a set of ten backup codes, each eight digits long. Each code works only once. You can create a new set at any time, and the old set then stops working.
What is a Microsoft recovery code?
Microsoft gives you a single 25-character recovery code instead of a set of codes. You generate it in your account security settings, print it, and keep it somewhere safe. Generating a new code makes any previous code stop working.
Can I use a backup code more than once?
No. Each backup code works exactly once. After you use one, it becomes inactive, so cross it off your list. If you run out, create a new set while you can still sign in.
Where should I store backup codes?
Print them and keep the paper where you keep important documents, such as with your passport. Do not store them only on the phone you sign in with, and never share them with anyone who asks.
What if I never created backup codes and I am locked out?
You must use the service's account recovery process, which asks questions to prove you own the account. That process can take days and is not always successful, which is why creating backup codes in advance matters.
Do backup codes expire?
Google, Microsoft and GitHub do not give their codes a fixed expiry date in their help pages. A set stops working only when you create a new set, use every code, or delete it. Check your account settings if you are unsure.
Are backup codes the same as a recovery key?
They are similar but not identical. Apple, for example, does not offer backup codes. It offers an optional 28-character recovery key that replaces Apple's standard account recovery, and Apple cannot give you a new copy if you lose it.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against Google Account Help, Microsoft Support and the major services' own recovery-code pages.
How we write and fact-check →