TOTP 2FA Code Generator

Generate live TOTP codes from a Base32 secret key, verify existing codes, or create an otpauth:// URI for QR scanning. 100% client-side.

Last reviewed: April 2026

New to this tool? Click here for instructions

Base32 Secret
Digits
Period
------
Enter a secret key above
Enter a Base32 secret key to generate a TOTP code.

How to Use the TOTP Generator

To use the TOTP Generator, follow these steps:

1. Paste your Base32 secret key into the provided field. You can find this key in your 2FA setup page, usually shown as a text code below the QR code.

2. Watch the live TOTP code display. A 6-digit code appears and updates automatically every 30 seconds.

3. Match the settings (digits and period) to match your service's configuration. Most services use 6 digits and 30 seconds.

4. To verify a code, switch to Verify mode and enter the code you want to check. Ensure your device's time is synchronized to avoid clock skew.

When to Use the TOTP Generator

Use the TOTP Generator when you need to set up two-factor authentication (2FA) for a service that requires it. This includes popular services like Google, Facebook, and Twitter.

The TOTP Generator helps you generate and verify TOTP codes, ensuring secure access to your accounts.

How It Works

The TOTP Generator uses the Time-based One-Time Password (TOTP) algorithm, defined in RFC 6238. Here's a simplified explanation of how it works:

1. The current Unix timestamp is divided by the period (30 seconds) to get the time counter T.

2. HMAC-SHA1 is computed using the shared Base32-decoded secret key and the time counter T.

3. The last nibble (4 bits) of the HMAC is used as an offset to extract a 31-bit integer from the HMAC starting at that offset.

4. The extracted number is taken modulo 10^digits to get the final code (padded with leading zeros if needed).

Tips, Edge Cases, or Limitations

1. Ensure your device's time is synchronized to avoid clock skew issues.

2. Use only uppercase letters A-Z and digits 2-7 for the Base32 secret key.

3. Most services use 6 digits and 30 seconds for TOTP, but some enterprise apps may use 8 digits or 60-second periods.

4. For related security tools, consider using the HMAC Generator, Password Hasher, and Base64 Encoder.

Frequently Asked Questions

TOTP (Time-based One-Time Password) is a two-factor authentication algorithm defined in RFC 6238. It generates a short numeric code (typically 6 digits) that changes every 30 seconds, derived from the current Unix timestamp and a shared secret key.
Yes, it is safe to enter your 2FA secret here. The TOTP Generator is a client-side tool, meaning all computations are performed on your device, not on a server. This ensures that your secret key remains secure and is never transmitted over the internet.
The TOTP secret is encoded in Base32, which uses only uppercase letters A-Z and digits 2-7 (no 0, 1, 8, or 9). When you set up 2FA on a service, you typically see a QR code containing an otpauth:// URI that contains your Base32 secret.
Your TOTP code may not match due to clock skew. Ensure your device's time is synchronized. On Windows, run `w32tm /resync`. On Linux/macOS, enable NTP.
An otpauth:// URI is a URL-encoded string that contains all the necessary information to set up 2FA on a service. It includes the secret key, account name, issuer, and other parameters. You can generate an otpauth:// URI using the TOTP Generator and convert it to a QR code for scanning with Google Authenticator, Authy, or Bitwarden.

Quick reference

TOTP 2FA Code Generator Quick Reference
Algorithm Period (seconds) Digits Secret Key Format
HMAC-SHA256 30 6 Base32 encoded string
HMAC-SHA1 15 8 Base32 URL-safe
HMAC-SHA512 60 10 Base32 with padding
Custom HMAC 10 6 Hexadecimal string
SHA256 30 8 Base64 encoded
SHA1 20 6 Base32 without padding