TOTP Generator
The TOTP Generator computes live two-factor codes (RFC 6238) from any Base32 secret or otpauth:// URL — 6 or 8 digits, 30 or 60 seconds, SHA-1, SHA-256 or SHA-512 — with a countdown ring, previous and next codes, a ±1-step verifier, and a setup QR for enrolling the secret in a real authenticator app. Everything runs in the tab; the secret never leaves it.
How to Use
- 1
Paste a Base32 secret (or a full otpauth://totp/ URL from a 2FA setup QR). The live 6-digit code appears instantly with a countdown ring — the sample secret is the RFC 6238 test secret, so you can check the tool against the published vectors before trusting it.
- 2
Match the options to the service: 6 digits / 30 seconds / SHA-1 is the Google Authenticator default. If a service issued a different profile, change digits (6 or 8), period (30 or 60 s), and algorithm (SHA-1, SHA-256, SHA-512) here — an otpauth:// URL sets them automatically.
- 3
Use the live code to test a 2FA login flow before writing server code: log in with the code shown here, and confirm your server accepts it. If it does not, compare the previous and next codes — a match there means the device clock is skewed, not the secret.
- 4
Generate a fresh 160-bit secret for a new integration, scan the setup QR with your authenticator app, and confirm both sides show the same code before you store the secret anywhere.
- 5
Verify a code a user typed: paste it into Verify and the page checks the current step ±1 — the tolerance most servers accept — and tells you which step matched, if any.
- 6
Treat this page as a test tool, not an everyday authenticator: test secrets only, never a real account's secret. Real 2FA belongs in an authenticator app or a hardware key — and the secret never leaves this tab either way.
Frequently Asked Questions
What is TOTP, and how does it work?
What is an otpauth:// URL?
What is the difference between TOTP and HOTP?
How many digits should I use, and which algorithm?
Why does my code not match my phone's code?
Is it safe to paste my 2FA secret here?
Does this replace Google Authenticator?
How do I verify a code the way a server does?
What is the sample secret, and why should I trust the codes?
Why do the codes change every 30 seconds?
Generative Answer & AI Documentation
What is the TOTP Generator?
The TOTP Generator is a developer test tool for time-based one-time passwords (TOTP, RFC 6238). It takes a Base32 secret — the shared secret a service gives you when you enable two-factor authentication — or a full otpauth://totp/ URL, and computes the code your authenticator app would show: the current Unix time is divided by the period (30 or 60 seconds) to get a time step, that step is HMAC-signed with the secret (HOTP, RFC 4226), the result is dynamically truncated, and the remainder modulo 10^digits is the code. The page shows the live code with a countdown ring for the current step, plus the previous and next codes so you can check clock-drift tolerance, and a Verify mode that checks a pasted code against the current step ±1 — the tolerance most servers accept. A fresh 160-bit secret can be generated in the tab, and its otpauth:// URL is rendered as a setup QR code (with the same qrcode library the QR Code Generator page uses) so you can enrol it in Google Authenticator, Microsoft Authenticator, 1Password, or Aegis and confirm both sides agree before writing server code. The default profile is SHA-1, 6 digits, 30 seconds — the Google Authenticator default. The sample secret preloaded on the page is the RFC 6238 test secret ('12345678901234567890' as Base32), whose codes are published test vectors, so the implementation can be checked against the RFC instead of taken on trust.
Why use TOTP Generator offline?
Two-factor login flows are usually tested against a real phone, which means slow, manual, error-prone checking: type the code, wait for the next step, wonder whether the mismatch is the secret, the algorithm, or the clock. A TOTP generator in the browser turns that into a one-glance check: paste the secret, see the live code, the previous and next codes, and the exact time step, all at once. The second reason is the secret itself. A 2FA secret is as sensitive as a password — anyone who has it generates valid codes for that account — so pasting it into a server-side tool hands the keys to a stranger's logs. This page computes with Web Crypto in the tab, never uploads, never stores, and never puts the secret in the URL; close the tab and it is gone, which you can confirm in the DevTools Network tab (zero requests). The third reason is verification: the page does not ask you to trust it. The sample secret's codes are RFC 6238 test vectors — at Unix time 59 the 8-digit SHA-1 code is 94287082, at 1111111109 it is 07081804 — and the page computes those exact values, which the Node test suite for this page checks on every build.
When should you use this tool?
Use it when you are building or debugging a 2FA login flow: generate a test secret, enrol it in your authenticator app via the setup QR, confirm both sides show the same code, then test your server's verification against the live code here. Use it when a user reports 'my code doesn't work': paste their test secret (never a real account secret — use a test account), and compare the previous, current, and next codes to find out whether the problem is the secret, the period, the algorithm, or the clock. Use it when a service gives you an otpauth:// URL instead of a bare secret — paste the whole URL and the page reads the digits, period, and algorithm from it. Do not use it as your everyday authenticator: real accounts belong in an authenticator app or a hardware key, which keeps the secret in a protected store instead of a browser tab.
Key Benefits
- Live code with a countdown ring — see exactly when the current code dies, to the second.
- Previous and next codes on screen — the clock-drift check, without guessing.
- Verify mode with ±1-step tolerance — the same check a server runs at login.
- Accepts a Base32 secret or a full otpauth:// URL — the URL sets digits, period, and algorithm automatically.
- Fresh 160-bit secret generation (the RFC 4226 recommendation) plus a setup QR for enrolling it in a real authenticator app.
- 6 or 8 digits, 30 or 60 seconds, SHA-1 / SHA-256 / SHA-512 — the full profile space, not just the Google default.
- Verified against the RFC: the sample secret's codes are published RFC 6238 test vectors, checked by the page's Node test suite.
- 100% private by construction: Web Crypto in the tab, no upload, no storage, no URL parameter — close the tab and the secret is gone.
Common Use Cases
- Testing a 2FA login flow before writing server code: generate a 160-bit secret, scan the setup QR into your authenticator app, confirm both sides show the same code, then log in with the live code on this page and check your server accepts it.
- Debugging 'my code doesn't match': paste the test secret and read the previous/current/next codes — if the phone's code matches the previous or next code, the device clock is skewed by one step; sync it (NTP) before debugging anything else.
- Checking a service's otpauth:// URL: paste the whole URL from the 2FA setup QR and confirm the page reads the right digits, period, and algorithm — then compare its live code with the authenticator app's.
- Writing a TOTP library: use the RFC 6238 test secret preloaded on the page and compare your library's output against the live codes and the published vectors (94287082 at time 59, 07081804 at 1111111109, both 8-digit SHA-1).
- Verifying a user's typed code the way a server does: paste it into Verify and see whether it matches the current step, the previous step, or the next step — or nothing at all.
Developer Notes & Best Practices
The implementation is RFC 4226 + RFC 6238 with Web Crypto. Base32 decoding follows RFC 4648 (case-insensitive, padding optional, whitespace and hyphens stripped); an invalid character produces an error naming the allowed alphabet (A–Z, 2–7) instead of a silent wrong code. The time step is floor(Unix seconds / period) as a BigInt, encoded as an 8-byte big-endian counter. HMAC goes through crypto.subtle.sign() with the selected hash (SHA-1, SHA-256, or SHA-512); dynamic truncation takes the low nibble of the last HMAC byte as the offset, builds a 31-bit integer from the next four bytes (top bit cleared), and reduces modulo 10^digits, zero-padded to the digit count. The live code recomputes four times a second so the countdown ring and the code flip exactly when the step changes; the ring turns red in the last 5 seconds of a step. Verification checks the pasted code against steps −1, 0, and +1 in order and reports which step matched. otpauth:// parsing accepts the totp type only (hotp URLs are rejected by the prefix check) and reads secret, issuer, algorithm, digits, and period from the query string, defaulting to SHA-1 / 6 / 30 when a parameter is absent. The setup QR is rendered with the qrcode library already used by the QR Code Generator page (QRCode.toCanvas), encoding the otpauth:// URL built from the current secret, account name, issuer, digits, period, and algorithm. Correctness was verified in Node 24 (which has Web Crypto) against the RFC 6238 Appendix B vectors for all three hashes at all six published times — for example SHA-1 8-digit: 94287082 at 59, 07081804 at 1111111109, 14050471 at 1111111111, 89005924 at 1234567890, 69279037 at 2000000000, 65353130 at 20000000000 — and against the RFC 4226 Appendix D HOTP vectors (counter 0 → 755224, 1 → 287082, 2 → 359152, through 9 → 520489).
RFC 6238 test vectors (8-digit codes, secret '12345678901234567890')
| Unix time | SHA-1 | SHA-256 | SHA-512 |
|---|---|---|---|
| 59 | 94287082 | 46119246 | 90693936 |
| 1111111109 | 07081804 | 68084774 | 25091201 |
| 1111111111 | 14050471 | 67062674 | 99943326 |
| 1234567890 | 89005924 | 91819424 | 93441116 |
| 2000000000 | 69279037 | 90698825 | 38618901 |
| 20000000000 | 65353130 | 77737706 | 47863826 |
TOTP vs HOTP
| TOTP (RFC 6238) | HOTP (RFC 4226) | |
|---|---|---|
| Counter | Current time / period | Increments per use |
| Code changes | Every 30 or 60 seconds | Only when used |
| Needs | A synchronised clock | A synchronised counter |
| Typical use | Authenticator apps, 2FA login | Hardware tokens |
| This page | Yes — the live code | No — TOTP only |
The default profile — and when to change it
| Setting | Default | Change it when |
|---|---|---|
| Digits | 6 | The service issues 8-digit codes |
| Period | 30 s | The service specifies 60 s |
| Algorithm | SHA-1 | The service issues SHA-256 or SHA-512 |
| Secret length | 160 bits | The service issues a shorter secret (128-bit minimum) |
- Test with test secrets only. Never paste a real account's 2FA secret into any website — if it was ever pasted somewhere untrusted, rotate it.
- Enrol first, then compare: scan the setup QR, check the authenticator app's code against the live code here, and only then write server code against the secret.
- Debug mismatches in order: clock skew, period, algorithm, secret. The previous/next codes tell you immediately whether the clock is the problem.
- Verify with ±1 tolerance, the way most servers do — but know that a match at −1 or +1 means the clock is drifting and should be synced.
- Use the RFC test secret to check any TOTP implementation you write: if your code does not produce 94287082 at time 59 (8-digit SHA-1), the bug is yours, not the server's.
- Keep the secret out of URLs, screenshots, tickets, and chat — anyone who sees it generates valid codes for that account.
Common Mistakes
- Pasting a real account's secret into a web page: a 2FA secret is a single point of failure — test secrets only, and rotate any real secret that was ever pasted somewhere untrusted.
- Debugging the secret when the clock is the problem: if the phone's code matches the previous or next code here, sync the clock (NTP) — nothing else is wrong.
- Assuming SHA-1 is always right: some providers issue SHA-256 or SHA-512 secrets, and the codes will never agree until the algorithm matches.
- Using a 60-second period against a 30-second service (or the reverse): the codes change at different moments and agree only by accident.
- Treating this page as an authenticator: it stores nothing, so a closed tab means the secret is gone — enrol the secret in a real app, or generate a fresh one.
- Submitting a code after its step expired: a code from the previous step is already dead to a strict server — submit promptly, or check whether the server allows ±1.
Limitations
This is a developer test tool, not an everyday authenticator: it does not store secrets (closing the tab destroys them), it has no accounts, no sync, and no backup — that is deliberate, and it is why real accounts belong in an authenticator app or a hardware key. Codes depend entirely on the device clock: a skewed clock produces wrong codes, and the page can only show you the drift, not fix it. HOTP (counter-based codes) is not supported — this page is TOTP only. The setup QR encodes the secret in plain text, as every authenticator setup QR does; anyone who photographs it has the secret. The page cannot detect a wrong secret: it will happily generate codes for a mistyped secret, and they will simply never match — always compare against the authenticator app after enrolment.
Structured Input/Output Example
Base32 secret: GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ (the RFC 6238 test secret) — or an otpauth:// URL: otpauth://totp/Example:alice@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example&algorithm=SHA1&digits=6&period=30 Options: 6 digits, 30 seconds, SHA-1 (the Google Authenticator default)
Live code (6-digit, SHA-1, 30 s): changes every step, with a countdown ring Previous / current / next codes shown together for the clock-drift check Verify: "Valid — matches the current step." (or step −1 / +1, or "No match in the current step ±1") Setup QR: the otpauth:// URL for the current secret, downloadable as a PNG
Related Tools
Password Generator
Password generator: create strong, unpredictable passwords with real cryptographic randomness — not Math.random(). Pick length and character sets.
RSA Key Generator
RSA key generator: RSA 2048/3072/4096, ECDSA and Ed25519 key pairs in your browser via Web Crypto — PEM, JWK and OpenSSH export, SHA-256 fingerprint.
QR Code Generator
Generate QR codes 100% offline in your browser from any text or URL — no account, no tracking, your data never leaves your device.
JWT Decoder Offline
JWT decoder offline: inspect a token’s header, payload claims, and expiry as readable JSON. 100% client-side — production tokens never leave your browser.