TOTP Generator

Turn a Base32 secret — or the whole otpauth:// URI from a QR code — into the six-digit code an authenticator app would show, with a live countdown to the next one. It follows RFC 6238 and is verified against all six of the specification's published test vectors rather than against a screenshot, including the case that catches most implementations: one code in eight comes out wrong if the sign bit is not masked during truncation. The previous and next codes are shown too, since most servers accept one step either side to tolerate clock drift. Your secret stays in the page and is never sent anywhere. Use this for your own accounts — testing a 2FA integration, or getting in when your phone is not to hand.

Common settings

SettingUsual valueAlso seen
Digits68
Period30 seconds60
AlgorithmSHA-1SHA-256, SHA-512
Drift allowance±1 stepServer-dependent

When to use it

  1. Test a 2FA integration you are building.
  2. Get a code when your phone is not to hand.
  3. Check a secret works before committing to it.
  4. Verify an authenticator app and a server agree.
  5. Read a code from a QR code's otpauth URI.

How to Use

  1. Paste your Base32 secret, or the whole otpauth:// URI.
  2. Adjust digits, period or algorithm only if your service is unusual.
  3. Copy the code before the countdown runs out.

Features

  1. Verified against all six RFC 6238 test vectors
  2. Base32 in any case, spacing or padding
  3. otpauth:// URI parsing from a QR code
  4. 6 or 8 digits, SHA-1, SHA-256 or SHA-512
  5. Adjustable period
  6. Previous and next codes for clock drift
  7. Live countdown
  8. Secret never leaves your browser

FAQs

Is it safe to paste my secret here?

It stays in the page — you can confirm with your browser's network tab that nothing is sent. But be clear about what the secret is: on its own it generates codes forever, so it is a second factor in plain text. Use this for your own accounts, and prefer a proper authenticator app for day-to-day use, where the secret lives in device storage rather than a browser tab.

The code does not match my app. Why?

Almost always the clock. TOTP is time-based, so a device a minute out produces a different code; check your system time is syncing. Otherwise check the digits, period and algorithm — a few services use 8 digits, 60 seconds or SHA-256 rather than the usual 6, 30 and SHA-1.

Why show the previous and next codes?

Because most servers accept one step either side to tolerate exactly that clock drift. If the current code is rejected and you are near a boundary, the adjacent one often works.

What formats does the secret take?

Base32 in any case, with or without spaces, hyphens or padding — and the full otpauth:// URI from a QR code, from which the issuer, digits, period and algorithm are read automatically.

Why was my secret rejected?

Base32 has no 0, 1 or 8 — they were left out because they are confusable with O, I and B. If your secret contains one it was almost certainly mistyped, and the tool names the character.

Is this really RFC 6238?

Yes, and it is tested against the specification's own vectors for SHA-1 at 8 digits, which is a stronger check than comparing against one app. SHA-256 and SHA-512 are supported too.

Can it replace my authenticator app?

For a quick check, yes. As a permanent arrangement, no — a browser tab is not where a long-lived secret belongs, and an app keeps it out of anything that can read the page.

Technical Details

TOTP is HMAC over a counter, and the counter is the current Unix time divided by the period. The secret is Base32 — accepted here lowercase, spaced in groups of four, and with or without padding, because that is how services actually hand them out, and rejected with the offending character named when it contains 0, 1 or 8, which are excluded from the alphabet precisely because they look like O, I and B. Two details decide whether an implementation is correct. The counter is written as eight big-endian bytes through a DataView rather than with bit shifts: JavaScript's bitwise operators truncate to 32 bits, and a Unix timestamp divided by 30 already needs 31, so a shift-based version works until roughly 2038 and then silently produces wrong codes. The dynamic truncation then takes the low four bits of the digest's last byte as an offset, reads four bytes from there, and masks off the top bit. Skipping that mask makes one code in eight come out negative, and JavaScript's modulo of a negative number is negative — so the bug appears as an occasional code with a minus sign rather than as a consistent failure, which is exactly how it survives a casual test. This implementation is checked against all six RFC 6238 test vectors rather than against a screenshot of an authenticator app. The HMAC itself is the browser's Web Crypto, shared with the site's other hashing tools. The `otpauth://` URI a QR code contains is parsed too, including the issuer and the digits, period and algorithm parameters, because retyping a secret out of a QR code is where mistakes happen. The code refreshes on its own and shows the seconds remaining; the previous and next codes are shown as well, since most servers accept one step either side to tolerate clock drift. The secret stays in the page and is never sent anywhere — which is the only acceptable arrangement for a value that is, by itself, a second factor.

Security Tools

Security Tools

  • Passphrase Generator
  • JWT Generator & Decoder
  • CSP Generator
  • security.txt Generator
  • AES Encryption
  • Bcrypt Hash Generator
  • BIP39 Mnemonic Generator
  • CVSS Calculator