2FA code generator

Make a new two-factor secret and QR code for your app, or enter a secret to see its current code. For developers testing 2FA, and for checking an authenticator app.

––––––
QR code for an authenticator app

This free TOTP generator works in your browser. Everything runs in your browser. Nothing you type is sent anywhere or stored. All inputs and calculations run locally on your device without server uploads; details on browser processing and storage are set out in the privacy policy.

How TOTP works

Your phone and the service share a secret. Every 30 seconds, both combine the secret with the current time using HMAC-SHA1 (RFC 6238) and take 6 digits from the result. Because both know the secret and the time, they get the same code without talking to each other. That is why authenticator apps work offline, and why a phone with the wrong clock produces wrong codes.

Uses

  • Developers: create a test secret and QR code, then check that your server accepts the codes.
  • Check that an authenticator app and a server agree, when a code keeps being rejected.
  • See the next code, to avoid typing one that is about to expire.

Keep secrets safe

Anyone with the secret can make your codes. This page runs entirely in your browser and stores nothing, but treat real account secrets like passwords: do not paste them into sites you do not trust, and do not use this page as your everyday authenticator. Keep backup codes when you set up 2FA.

Worked example: Generating a 6-digit RFC 6238 code from a Base32 secret

Time-based One-Time Passwords (TOTP, RFC 6238) combine a shared Base32 secret key with the current 30-second Unix time counter (T = floor(unix_seconds / 30)). Try entering the standard test secret:

  • Base32 secret input: JBSWY3DPEHPK3PXP (which decodes to the 10-byte ASCII string Hello!\xDE\xAD\xBE\xEF).
  • Step 1 — 30-second time step (T): At Unix timestamp 1,763,100,000 seconds (2025-11-14T06:00:00Z), dividing by 30 gives counter T = 58,770,000 (0x000000000380C550 as an 8-byte big-endian integer).
  • Step 2 — HMAC-SHA1 & dynamic truncation: The browser computes HMAC-SHA1(secret, T) (producing 20 bytes), reads the last 4 bits as an offset (0..15), extracts 4 bytes starting at that offset, masks the sign bit (& 0x7fffffff), and takes modulo 1,000,000 to produce the 6-digit code (padded with leading zeros if needed), refreshing every 30 seconds on :00 and :30.

Limits and what this tool cannot do

  • Requires an accurate system clock on your device: Because TOTP codes change every 30 seconds based on UTC Unix time, if your computer or phone clock is off by more than 30 to 60 seconds, the generated 6-digit code will not match the server's expected code.
  • Base32 alphabet (A–Z and digits 2–7 only): Standard TOTP secrets use RFC 4648 Base32, which does not include the digits 0, 1, 8, or 9. Spaces and hyphens typed into the secret box are ignored automatically.
  • Does not store your 2FA secrets across sessions: Closing the tab clears the secret from memory; use a dedicated authenticator app or password manager for permanent storage, and use this tool for testing 2FA onboarding flows or emergency code generation.

Questions

Why does my code not work?

Most often the device clock is wrong. Turn on automatic time. Also check the digits, period and algorithm match what the service expects; almost all use 6 digits, 30 seconds and SHA-1.

Is this compatible with Google Authenticator?

Yes. Scan the QR code with Google Authenticator, Microsoft Authenticator, Authy or 1Password and the codes will match.

Is the secret sent anywhere?

No. Everything runs in your browser. Nothing you type is sent anywhere or stored.

Why is my 6-digit TOTP code rejected by the server even though the secret is right?

Check your device's clock synchronization (time.is or OS automatic network time). Even a 45-second clock drift puts your browser in the previous or next 30-second time window.

What does the 'otpauth://totp/...' URI inside the QR code look like?

Scanning the QR code with Google Authenticator, Authy, or 1Password reads a URI formatted as otpauth://totp/Issuer:Account?secret=BASE32SECRET&issuer=Issuer&algorithm=SHA1&digits=6&period=30.

Is my 2FA secret key transmitted over the internet when I type it here?

No. Both the HMAC-SHA1 calculation (via the browser's native crypto.subtle API) and the SVG QR code drawing happen 100% offline inside your browser tab.

Last reviewed .

Related converters and guides