
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 2026New to this tool? Click here for instructions
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
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 |