TOTP code generator
Paste the Base32 key shown under the QR code, or the otpauth:// link inside it. Codes are calculated in your browser, and the secret isn't sent anywhere.
Settings: SHA1, 6 digits, 30 seconds
Most apps use SHA1, 6 digits and 30 seconds. Change these only if the account's setup says so.
Enter a secret key to see the current code, or use a random secret to try it out.
How to use this TOTP generator
- Paste the account's secret key, or the whole otpauth:// link from its QR code. Spaces and lowercase letters are fine.
- The current code appears straight away, with a countdown to the next one. Copy it before the countdown runs out, or use the next code if it's about to change.
- If the account uses different settings, open Settings and choose the algorithm, number of digits and period. A pasted otpauth:// link sets these for you.
- To try it without an account, choose Use a random secret. You get a new secret, its code and an otpauth:// link you can give to a test user.
What is a TOTP generator?
TOTP stands for time-based one-time password. When you turn on two-factor sign-in with an authenticator app, the website and the app share a secret key. From then on, both calculate the same code from that secret and the current time, and the code changes every 30 seconds.
A TOTP generator does the same calculation as the app. It's useful when you need a code somewhere other than your phone: checking a new account's setup, signing in a test user or debugging why a code is rejected. Read what TOTP is and how it works for the details of the calculation.
Where to find a TOTP secret key
Websites show the secret when you set up two-factor sign-in, usually as a QR code. Most also offer the key as text, behind a link such as "Can't scan the code?" or "Enter a setup key". It's a string of letters A to Z and digits 2 to 7.
The QR code itself contains an otpauth:// link with the secret, the account name and the settings. If your app or test environment gives you that link, paste the whole thing.
Generate TOTP codes in automated tests
An end-to-end test can't scan a QR code into a phone, but it doesn't need to. With MailSlurp virtual TOTP devices, your test reads the otpauth:// link or secret your app shows during enrollment, creates a device paired with it, and requests a code whenever the sign-in form asks for one.
- Finish two-factor enrollment for a new test user with a real code.
- Sign out and back in to check that a returning user gets through.
- Check that an expired or reused code is rejected.
The same account gives each test real email inboxes and phone numbers, so one test can cover email, SMS and authenticator codes.
Let AI agents sign in with TOTP
AI agents that sign up for services or run tests hit the same two-factor prompts. Connect Claude, ChatGPT or your own agent to MailSlurp over MCP, assign it a virtual TOTP device, and it can generate a code for the sign-in steps you allow, without access to anyone's phone.
The agent can also have its own email address and phone number for email and SMS codes. Each is assigned separately, so it only uses what you give it. See SMS and TOTP for agents and giving an AI agent its own email address and phone number.
Keep TOTP secrets safe
A TOTP secret works like a password: anyone who has it can generate your codes. This page calculates codes in your browser and doesn't send or save the secret, but the safest place for a real account's secret is still your authenticator app or password manager.
- Use this tool for test accounts, new setups and troubleshooting.
- Don't share screenshots or logs that show a secret or an otpauth:// link.
- If a secret may have been exposed, turn two-factor sign-in off and on again to get a new one.
FAQ
What is a TOTP generator?
A TOTP generator calculates the time-based one-time password for an account from its secret key and the current time. It produces the same six-digit code an authenticator app such as Google Authenticator or Microsoft Authenticator shows for that account.
Is it safe to paste my secret key here?
The code is calculated in your browser with the Web Crypto API, and the page doesn't send or store the secret. Even so, a TOTP secret is a credential: for a real account, keep it in your authenticator app or password manager, and use this tool for test accounts and setup checks.
Why doesn't my code match the one in my authenticator app?
Check that the secret is complete and from the current setup, since resetting two-factor sign-in creates a new secret. Then check the settings: most accounts use SHA1, 6 digits and 30 seconds. Finally, check the device clock, because TOTP codes depend on the time.
What is the difference between a TOTP and an OTP?
An OTP is any one-time password. A TOTP is a kind of OTP calculated from a shared secret and the time, so it changes every 30 seconds without being sent. Codes delivered by SMS or email are OTPs that the server generates and sends instead.
Can I generate TOTP codes in automated tests?
Yes. MailSlurp virtual TOTP devices are paired with a test user's otpauth:// link or Base32 secret through the API, and return a fresh code whenever your Playwright, Cypress, Selenium or API test needs one.
Can an AI agent use TOTP codes?
Yes. With MailSlurp, an AI agent connected over MCP can generate codes from the virtual TOTP devices assigned to it, alongside its own email inbox and phone number, for the sign-in steps you authorize.