TOTP Generator
Generate live TOTP two-factor codes from a base32 secret — RFC 6238, computed on your device, with the current code, a countdown and the next code.
TOTP (RFC 6238) turns a shared secret and the current time into a code that changes every 30 seconds: the time is divided into 30-second steps, each step number is fed as a counter into HOTP (RFC 4226) — HMAC-SHA-1 over the 8-byte counter, dynamically truncated to 31 bits — and the result is taken modulo a million for 6 digits. The published test values pin the maths down exactly: with the RFC demo secret (the ASCII string 12345678901234567890, base32 GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ), counter 0 gives HOTP 755224 and counter 1 gives 287082; at time 59 seconds the 8-digit TOTP is 94287082 (the same code as the 6-digit 287082), and at time 1234567890 it is 89005924. This page reproduces those vectors with its own hand-written SHA-1, so the codes it shows are the codes any standard authenticator would show for the same secret.
Your secret is processed only on this device and is cleared when you close this page — it lives only in page memory, is never sent anywhere, never stored, and never written into the page address. A TOTP secret is as powerful as the codes it makes: never share a TOTP secret with anyone, never paste one into a site you do not fully control, and treat a secret you have pasted anywhere else as compromised. Codes are 6 digits, change every 30 seconds, and follow RFC 6238 (HOTP from RFC 4226, HMAC-SHA-1).
Quick answers
How does a TOTP code get generated?
Divide the current Unix time by the 30-second period to get a counter, run HMAC-SHA-1 of that counter with the shared secret (HOTP, RFC 4226), truncate dynamically and take the last 6 digits. With the RFC demo secret, time 59 gives 94287082 as an 8-digit code and 287082 as a 6-digit code.
This page implements SHA-1 and HMAC by hand and reproduces the RFC 4226 and RFC 6238 test vectors exactly, so its codes match any standard authenticator for the same secret.
How long is a TOTP code valid?
One 30-second window: the code for the window starting at second 30 of a minute is valid until second 59. At time 59 exactly 1 second remains. Many services also accept the previous and next window to absorb clock drift, which is why a just-expired code sometimes still works.
The countdown on this page counts to the window boundary, and the next code is shown so you can wait out the last seconds instead of racing them.
How to use
- Paste the base32 secret — the string an authenticator setup shows under “enter this key manually”. Spaces and hyphens are ignored and lowercase is fine.
- Read the current 6-digit code and the countdown: codes are computed from the current 30-second window, so a code shown with 2 seconds left is about to change.
- The next code is shown alongside, which is handy when a form is slow — wait for the window to roll over rather than racing the last seconds.
- Close the page when you are done: the secret lives only in page memory and is cleared when you close. Never share a TOTP secret with anyone.
About this tool
The security model deserves one honest paragraph. A TOTP secret is not like a password you can type from memory — whoever holds the secret can generate valid codes forever, which is why setup screens warn you to guard it and why this page processes it only on your device and clears it when you close. Use this tool to test an integration, recover access to an account whose secret you legitimately hold, or check a server implementation against a known-good client. Do not use it as your daily authenticator: a phone authenticator keeps the secret in a dedicated app, while a browser page is one careless paste away from leaking it. If a secret has ever been pasted into a site you do not control, treat it as compromised and re-enrol that account with a fresh secret.
Frequently asked questions
Why is my code being rejected by the site?
Almost always the clock. TOTP is time in disguise: if your device clock is a minute or more off, every code is wrong even though the secret is right. Check that your device sets its time automatically. The other classic cause is a mistyped secret — one wrong base32 character gives consistently wrong codes, not intermittent ones.
What is the difference between the 6-digit and 8-digit codes?
Only the final modulo: the same 31-bit truncated value is reduced modulo 10^6 for 6 digits or 10^8 for 8. At time 59 with the RFC demo secret the value gives 94287082 in 8 digits and 287082 in 6 — the last six digits agree. Most services use 6; this page shows 6, the common case.
Is it safe to paste my real secret here?
The computation happens entirely in this page on your device — the secret is processed only on this device, is never sent anywhere, and is cleared when you close the page. That said, the disciplined habit is to keep real secrets in your authenticator app and use this tool with test secrets or for a one-off recovery, then close the page.
Why does the code change exactly on the half minute?
The counter is the Unix time divided by 30, floored — so windows run 00–29 and 30–59 seconds of every minute, worldwide, regardless of time zone. At 59 seconds exactly 1 second remains in the window, which the countdown shows.
First time embedding? Read the step-by-step guide →
More free tools
UUID Generator
Generate random v4 UUIDs in bulk.
JSON Formatter & Validator
Format, minify and validate JSON in one click.
What Is My IP
See your public IP address instantly. No sign-up, nothing stored.
Regex Tester
Test, check and validate regular expressions with live highlighting.
JWT Decoder
Decode a JWT token without the secret — see its header and payload.
SHA-256 Hash Generator
Generate SHA-256 / SHA-512 hashes instantly.