2FA code generator: get your TOTP code in the browser
Paste a Base32 secret or an otpauth link and get the current 2FA code with its countdown, the same code an authenticator app shows. It is computed in your browser; the secret is not sent or stored.
Runs in your browser. What you type stays on this page.
2FA code generator
Runs in your browser. What you type stays on this page.
How a 2FA code is made
The 6-digit code of an authenticator app is a TOTP, a time-based one-time password defined in RFC 6238. It comes from two things only: the secret key the service gave you when you turned on two-factor authentication, and the current time. This page runs the same calculation in your browser with the Web Crypto API, so it shows the same code as an app that holds the same secret.
The formula: the time step T is the Unix time divided by the period, 30 seconds by default, rounded down. The tool signs T with HMAC-SHA-1 using the secret as the key, cuts the result to a 31-bit number by the dynamic truncation of RFC 4226, and keeps the remainder of dividing it by 1,000,000, padded with zeros to 6 digits.
Press Try an example and the tool loads the demo secret JBSWY3DPEHPK3PXP. At Unix time 1,700,000,000 (14 November 2023, 22:13:20 UTC) the step is 56,666,666, the code is 324 550 and it has 10 seconds left; the previous code was 822 542 and the next is 367 665. With 8 digits, the same step gives 0232 4550.
How to use it
- Paste the secret into Secret key or otpauth link: the Base32 key the service shows beside its QR code, or the whole otpauth://totp/ link. Spaces, dashes and lower case are fine. To see it work first, press Try an example.
- If you have the QR code only as an image, press Read QR code from an image and pick the file. The button shows only in browsers that can read QR images.
- Read the Current code and the countdown under it, New code in followed by the seconds left, and copy the code with the button beside it.
- If the service uses 8 digits, 60 seconds, SHA-256 or SHA-512, open Advanced and set Digits, Period and Algorithm. An otpauth link fills them in for you.
- If the code is refused because it changed while you typed or your clock is a little off, try the Previous code or the Next code. Press Clear when you finish to wipe the secret from the page.
Where to find the secret key
When you turn on two-factor authentication, the service shows a QR code and, often behind a link such as can’t scan it, the same secret as text. That text is the Base32 key: letters A to Z and digits 2 to 7, often printed in groups of four. Base32 has no 0, 1, 8 or 9, so a key with one of them was copied wrong.
The QR code itself holds an otpauth://totp/ link with the secret, the account name, the issuer and, when they differ from the defaults, the digits, period and algorithm. Paste that link and the tool shows the issuer and account under Account and fills in the Advanced options. Links for counter-based codes (otpauth://hotp/) are refused: this tool makes time-based codes only.
Why a 2FA code is rejected
The usual cause is the clock. The code depends on the time, so a device whose clock is off by more than the period produces a different code from the service. Set the date and time to update automatically and try again.
Next come the settings: a service that uses 8 digits, a 60-second period or SHA-256 gives codes that never match the defaults. Then the secret itself, when a character was lost or changed in the copy. And a code typed in its last seconds may reach the service after it changed: the Previous code and Next code rows show the codes either side, and whether the service accepts them is up to the service.
Digits, period and algorithm
Most accounts use 6 digits, a 30-second period and SHA-1, which is what the tool starts with. It also makes 8-digit codes, 60-second periods and SHA-256 or SHA-512 codes. Change them only when the service says so, or let an otpauth link set them.
A link with any other value, such as 7 digits, a 15-second period or another algorithm, gets an error that names what the tool cannot make, instead of a code that would never match.
Keep the secret safe
The secret is the whole second factor: whoever holds it can make your codes. Paste it only for accounts you own or are allowed to manage, and never send it in a chat or a screenshot. The field hides what you paste until you press Show secret.
This tool computes the code in your browser and keeps no history: the secret is never sent, Clear wipes it, and your browser’s network tab shows that no request carries it. For high-value accounts, an authenticator on a device you trust or a hardware security key is still the better place for the secret. When a team runs many ad accounts, give each person their own access where the platform allows it, instead of passing one login and its secret around.
Recovery codes and a lost device
When you turn on 2FA, most services also give you recovery codes, sometimes called backup codes. Each one works once and lets you sign in without the code. Keep them offline, away from the device that makes your codes.
If you lose that device, sign in with a recovery code or with the secret you saved, and set up 2FA again. Without either, only the service’s own account recovery can help.
Questions
What is a 2FA code?
It is a short one-time code, usually 6 digits, that you type after your password to prove you hold the second factor. A TOTP code changes every 30 seconds, or every 60 on some services.
Where do I find the secret key?
On the screen where you turn on two-factor authentication, next to the QR code, often behind a link for when you cannot scan it. That Base32 key, or the otpauth link inside the QR code, is what you paste here.
Is my secret key sent to a server?
No. The code is computed in your browser with the Web Crypto API; the secret is not sent or stored, and there is no history. Clear wipes the secret from the page.
Why does the service say the code is invalid?
Most often the device clock is off: set the time to update automatically. Then check that the secret was copied whole and that the digits, period and algorithm match what the service uses.
Is it the same code an authenticator app shows?
Yes, when the service uses standard TOTP (RFC 6238) and both hold the same secret and settings, the codes are the same.
Can I scan the QR code with my camera?
No, the tool does not use the camera. Where the browser can read QR images, Read QR code from an image reads a screenshot or photo of it in this tab.
What are recovery codes?
One-time backup codes a service gives you when you turn on 2FA. Store them offline: they let you sign in if you lose the device that makes your codes.
Can I use it for any account?
Use it only for accounts you own or are allowed to access. It makes codes from a secret you already have; it cannot bypass or recover a 2FA you do not control.
Related tools
PubWeb
Running many ad accounts? See campaign ROI in one panel.
PubWeb lists your Meta, TikTok and Kwai campaigns with cost, CPA, revenue and ROI per project, in the same panel as your Ad Manager pricing, site analytics and push.