TOTP Generator
Generate time-based one-time passwords (RFC 6238) entirely in your browser.
Current Code
30s remainingEnter a valid Base32 secret above to generate codes.
Algorithm: HMAC-SHA1 (RFC 6238)
Period: 30 seconds
Digits: 6
Crypto: SubtleCrypto — runs entirely in your browser
Last updated:
Generate TOTP codes from a secret key
This TOTP generator creates 6-digit, time-based one-time passwords from a Base32 secret key. It shows the current code with a 30-second countdown, plus the previous and next codes. It is made for testing two-factor login (2FA) while you build or debug an app.
How to use it
- Enter your Secret Key (Base32). A sample key,
JBSWY3DPEHPK3PXP, is filled in so you can try it right away. - Read the Current Code. The bar and the seconds counter show how long it stays valid.
- Click Copy to copy the current code.
- Compare it with the Previous (−30s) and Next (+30s) codes if your server allows a time window.
How it works
The tool follows RFC 6238 with fixed settings: HMAC-SHA1, a 30-second period and 6 digits.
- The secret is decoded from Base32. Spaces and trailing
=padding are ignored, and lowercase letters are turned into capitals. - The time step is the current Unix time divided by 30, rounded down.
- The step is written as 8 bytes and signed with HMAC-SHA1 using the decoded key.
- Dynamic truncation picks 4 bytes from the signature. The number is taken modulo 1,000,000 and padded to 6 digits.
The HMAC is done with your browser's Web Crypto API (SubtleCrypto). The secret and codes are not sent to a server.
Tips
- Use test secrets only. Never paste a real production secret into any web tool.
- Codes depend on your device clock. If they do not match your app, check that the clock is set correctly.
- Only the letters A–Z and digits 2–7 are valid Base32. Any other character shows an error.
- The period, digit count and algorithm cannot be changed. Keys set up for 8 digits, 60 seconds or SHA-256 will not match.
Frequently asked questions
Will these codes match Google Authenticator?
Yes, for standard keys that use SHA-1, 6 digits and 30 seconds, which is the usual default. The clocks on both devices also need to be correct.
Why do I see an "Invalid Base32 character" error?
The key contains a character outside A–Z and 2–7, such as 0, 1, 8 or 9. Check that you copied the full secret correctly.
Why does it show the previous and next codes?
Many servers accept a code from one step before or after the current one to allow for clock drift. Seeing all three helps you debug a login check.
Related Security
Browse all tools from the same category.
Random Token Generator
UUID, API key, CSRF token, and hex strings in bulk
Open toolJWT Key Generator
Bulk-generate cryptographically secure JWT signing keys
Open toolShowing 1-2 of 7