Skip to main content

Free TOTP Code Generator – Test & Verify Your 2FA Setup

Generate time-based one-time passwords (TOTP) from a Base32 secret for testing and verifying your own 2FA setup. Supports SHA-1/256/512, 6-8 digits, and otpauth URIs — nothing is stored.

Written & reviewed by Helperzy Editorial Team · Updated July 2026

RFC 6238HMAC-SHA1/256/512WebCryptoNo StorageFree

For testing & debugging only

This tool is for verifying your own 2FA setup, not a replacement for an authenticator app. Your secret is held in memory only — it is never saved to localStorage, never sent anywhere, and disappears when you close this tab.

100% Private

Your secret key lives only in React state for this session. It is never written to localStorage, never sent to any server, and disappears the moment you close or refresh this tab. HMAC is computed via your browser's built-in WebCrypto API.

How to Use TOTP Code Generator

1

Enter Your Base32 Secret or otpauth URI

Paste the Base32 secret from your 2FA setup, or the full otpauth URI from a QR code. When you paste a URI, the tool reads the secret, issuer, digit count, and period automatically so you do not have to configure them by hand.

2

Choose the Algorithm, Digits, and Period

Leave SHA-1, 6 digits, and 30 seconds for the common case, or adjust them to match a service that uses SHA-256, eight-digit codes, or a 60-second window. The generated code updates live as the settings change.

3

Read the Current, Previous, and Next Codes

A countdown ring shows the time left in the current window. The previous and next codes appear alongside the current one, which helps you diagnose clock-drift problems where a code is valid for an adjacent time window.

How TOTP Works and Why This Generator Is for Testing

A TOTP code generator produces the same six-digit rotating codes that authenticator apps like Google Authenticator or Authy show when you set up two-factor authentication on an account. TOTP stands for Time-based One-Time Password, defined in RFC 6238, and it is the mechanism behind that familiar enter-the-6-digit-code screen during login. This tool exists for developers testing a 2FA integration, sysadmins debugging why a code will not accept, and anyone who wants to confirm their own secret key produces the expected code before relying on it, without needing a phone in hand. It is explicitly not meant to replace an authenticator app for day-to-day logins; treat it as a testing and verification instrument for setups you already own. The algorithm starts from a shared secret, typically given as a Base32 string, which gets decoded into raw bytes. A counter value is computed as the current Unix time divided by the period (usually 30 seconds) rounded down, then packed into an 8-byte big-endian buffer. That counter is HMAC-signed using the secret as the key, with SHA-1 as the RFC 6238 default, though SHA-256 and SHA-512 are also supported since some services use them. The resulting HMAC output undergoes dynamic truncation: the low four bits of the last byte become an offset, four bytes are read starting at that offset, the top bit is masked off to keep the number positive, and the resulting 31-bit integer is taken modulo ten to the power of the digit count, then padded with leading zeros to the requested length. RFC 6238's own Appendix B test vectors use the ASCII secret 12345678901234567890 with SHA-1 and a 30-second period. At Unix time 59, which is inside the very first 30-second window after the epoch, the algorithm produces the eight-digit code 94287082. At Unix time 1111111109 it produces 07081804, and one second later at 1111111111 it produces a different code, 14050471, showing the code changes the instant a new 30-second window begins. At 1234567890 the code is 89005924, and at 2000000000 it is 69279037. This tool reproduces every one of those five values exactly, which is the standard way to confirm any TOTP implementation, including an authenticator app itself, is computing codes correctly. A developer wiring up TOTP-based 2FA for a new signup flow can generate a test secret, feed it into both this tool and their own backend verification code, and confirm the two produce matching digits before ever touching a real phone or QR code. Someone migrating between password managers or authenticator apps can paste an otpauth URI extracted from a QR code to double-check the secret, issuer, digit count, and period were captured correctly during migration, catching a misconfigured period or digit count before it locks them out. IT support staff troubleshooting a my-code-never-works ticket can paste a user's secret with consent, in a secure session, and watch whether the previous, current, and next codes line up with what the user reports seeing, which usually reveals a clock-drift issue rather than a broken secret. The most common real-world TOTP failure is clock drift: if the device generating codes and the server verifying them disagree on the time by more than roughly one period, codes will consistently fail even though the secret is correct, which is why this tool shows the previous and next code alongside the current one, so you can tell whether a slightly-off code is actually valid for an adjacent window. Never paste a real, production 2FA secret into any tool you do not fully trust and control; this one is safe by design because the secret lives only in memory for your current browser session. It is never written to storage, never sent to any server, and disappears the moment you close or refresh the tab.

TOTP Code Generator Formula & Method

counter C = floor(unixTime / period). HMAC = HMAC-SHA1(secretBytes, 8-byte big-endian C). Dynamic truncation (RFC 4226): offset = HMAC[19] & 0x0F; binCode = (HMAC[offset] & 0x7F)<<24 | HMAC[offset+1]<<16 | HMAC[offset+2]<<8 | HMAC[offset+3]. Code = binCode mod 10^digits, zero-padded. RFC 6238 vector: secret 12345678901234567890, SHA-1, T=59 -> 94287082 (8-digit).

Examples: TOTP Code Generator

Input

Secret 12345678901234567890 (ASCII), SHA-1, 8 digits, T=59

Result

94287082

RFC 6238 Appendix B test vector — the first 30-second window after the epoch. The 6-digit form is the last six digits, 287082.

Input

Same secret, T=1111111109

Result

07081804

A published RFC 6238 vector confirming correct HMAC-SHA1 and dynamic-truncation behaviour across a later time window.

Input

Same secret, T=1111111111 (one second later)

Result

14050471

Crossing into the next 30-second window produces a completely different code, demonstrating how TOTP rotates on the period boundary.

Frequently Asked Questions – TOTP Code Generator

No. It is a testing and verification tool, not a daily 2FA app. Use it to confirm a secret produces the expected codes, debug a failing setup, or check a migration. For everyday logins, keep using a dedicated authenticator app that stores your secrets securely.