Complete Guide to TOTP Generator: Two-Factor Authentication Made Simple
Learn how to generate TOTP 2FA codes and QR codes for authenticator apps. A complete tutorial for secure two-factor authentication.
Free Interactive Tool
TOTP 2FA Generator
Generate TOTP 2FA codes and QR codes for authenticator apps. Supports otpauth:// URIs, multiple accounts, and backup export. 100% client-side.
Table of Contents
In an era where data breaches and credential theft make headlines almost weekly, relying on a single password to protect your online accounts is no longer enough. Two-factor authentication (2FA) adds a critical second layer of security β and Time-based One-Time Password (TOTP) is the most widely adopted standard for generating those second-factor codes. Whether you're logging into your email, your GitHub account, or a corporate VPN, TOTP provides a time-sensitive, algorithmically generated code that only you β and your authenticator app β can produce.
Our TOTP Generator makes working with TOTP straightforward and transparent. Instead of juggling multiple authenticator apps or worrying about vendor lock-in, you can generate current 2FA codes directly from any secret key or otpauth:// URI, scan the associated QR code for syncing with your phone, and export your accounts for safe backup β all within your browser. Best of all, every operation runs 100% client-side using the Web Crypto API, so your secrets never leave your machine.
Why Use a TOTP Generator?
- Enhanced Security β TOTP adds a second factor that changes every 30 seconds, making stolen passwords useless on their own.
- Offline-Capable β Once the shared secret is loaded, time-based codes are generated locally with no internet connection required.
- Multiple Accounts β Manage all your TOTP-protected accounts in one place β social media, email, development platforms, and more.
- Backup Export β Export your account list (encrypted secrets and labels) so you can restore everything if you lose access to your device.
- 100% Client-Side β Your secret keys are never transmitted, stored on a server, or logged. The Web Crypto API handles all cryptographic operations right in your browser.
Key Features
| Feature | Description |
|---|---|
| Secret Key & URI Input | Paste a raw Base32 secret key or a full otpauth:// URI β the tool parses both automatically. |
| Current Code Generation | Generates the current 6-digit TOTP code using the standard HMAC-SHA1 algorithm with a 30-second window. |
| QR Code Display | Renders a scannable QR code of the otpauth:// URI so you can sync it with any authenticator app on your phone. |
| Countdown Timer | Shows a live countdown to the next code refresh so you always know when a new code is about to be issued. |
| Multiple Accounts | Add, label, and manage several TOTP accounts in a single session. |
| Backup Export | Export all your accounts as a JSON file for safekeeping or migration. |
The tool supports the standard otpauth:// URI format defined by the Google Authenticator specification:
otpauth://totp/ISSUER:LABEL?secret=BASE32SECRET&issuer=ISSUER&algorithm=SHA1&digits=6&period=30
For example, a GitHub TOTP URI might look like this:
otpauth://totp/GitHub:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=GitHub&algorithm=SHA1&digits=6&period=30
How to Use
Follow these four simple steps to start generating TOTP codes with our TOTP Generator:
Step 1: Enter Your Secret Key or URI
When you enable 2FA on a supported service (e.g., GitHub, Google, or your email provider), you'll receive a shared secret β typically a Base32-encoded string β or a QR code containing an otpauth:// URI. Paste the secret key directly into the input field, or paste the full URI. The tool auto-detects the format and parses the issuer, label, and secret.
Step 2: Generate the Current Code
Once the secret is loaded, the tool instantly computes the current 6-digit TOTP code using the system time, the shared secret, and the HMAC-SHA1 algorithm. A countdown timer shows the seconds remaining until the code refreshes (every 30 seconds).
Step 3: Scan the QR Code
A QR code is automatically generated from the otpauth:// URI. Scan it with your mobile authenticator app (Google Authenticator, Authy, Microsoft Authenticator, etc.) to sync the account to your phone. This is useful if you want the same TOTP seed available on multiple devices.
Step 4: Export Your Backup
Click the export button to download a JSON file containing all your labeled accounts and their encrypted secrets. Store this file in a secure, offline location (e.g., an encrypted USB drive or a password manager's secure notes). If you ever lose your device, you can re-import the backup and restore all your 2FA codes instantly.
Understanding TOTP Concepts
TOTP (Time-based One-Time Password) is defined in RFC 6238 and builds on the HMAC-based One-Time Password (HOTP) algorithm from RFC 4226. Here's how it works under the hood:
- Time-Based β Instead of using a counter (as HOTP does), TOTP uses the current Unix time as its moving factor. The time is divided into fixed time steps, typically 30 seconds.
- 30-Second Window β The code is valid only for the current 30-second window. Once the window expires, a new code is generated. This limits the window of opportunity for an attacker who intercepts a code.
- HMAC-SHA1 Algorithm β The shared secret and the time counter are combined using HMAC-SHA1 to produce a 20-byte hash. A dynamic truncation process extracts a 6-digit code from that hash. SHA-256 and SHA-512 are also supported by the standard, but SHA-1 is the most widely deployed.
- Shared Secret β The secret is a random Base32-encoded string (typically 16β32 characters) generated by the service when you enable 2FA. This secret is known only to you and the service β it's the cryptographic seed that ensures both sides produce the same code at the same time.
This elegant design means that even if an attacker steals your password, they cannot log in without the current TOTP code β which they cannot generate without the shared secret.
Practical Use Cases
Securing Social Media Accounts
Protect your Twitter, Facebook, Instagram, or LinkedIn accounts by enabling 2FA. Use our TOTP Generator to generate codes on your desktop while keeping your phone as a backup authenticator. This is especially useful when you're working at your computer and don't want to reach for your phone every time you log in.
Enabling 2FA on GitHub
GitHub supports TOTP-based 2FA for all accounts. When you enable it in your GitHub settings, you'll be given a secret key and a QR code. Paste the secret into our tool to start generating codes immediately. This is a critical step for any developer β a compromised GitHub account can lead to leaked source code, exposed API keys, and supply-chain attacks.
Team Vault Access
Many team password managers (like Bitwarden, 1Password, or Keeper) allow TOTP seeds to be stored alongside login credentials. Generate the 2FA code in our tool when accessing shared vaults from a shared or public computer, or use the export feature to migrate your TOTP accounts between devices.
API Authentication
Some services require TOTP codes as part of API authentication flows, especially for sensitive operations like withdrawing funds, changing account settings, or provisioning new API keys. Generate the current code on demand to complete these operations without needing your phone.
Best Practices
- Store Your Secrets Securely β Never store TOTP secret keys in plaintext files, unencrypted notes, or cloud documents. Use a password manager's secure notes, an encrypted USB drive, or a hardware security key.
- Use Multiple Authenticators β Configure the same TOTP seed on at least two devices (e.g., your phone and your desktop via our TOTP Generator). This prevents a single lost or broken device from locking you out of your accounts.
- Save Backup Codes β Most services provide one-time backup codes when you enable 2FA. Download and store these codes in a safe place β they are your emergency fallback if you lose access to all authenticator devices.
- Rotate Secrets Periodically β Disable and re-enable 2FA on your accounts every 6β12 months to generate fresh shared secrets. This limits the damage if a secret was ever compromised without your knowledge.
- Verify Before Removing the Old Method β When switching authenticators or migrating to a new device, always verify that the new setup generates the correct codes before removing the old one. Our tool makes this easy β compare the code shown on your new device with the code generated by our tool to confirm they match.
Start Securing Your Accounts Today
Two-factor authentication is one of the most effective steps you can take to protect your online identity. The TOTP Generator gives you a fast, secure, and private way to manage your 2FA codes β no app installation, no account creation, and no data leaving your browser.
Try it now: Generate your first TOTP code β
Related Tools You Might Like:
- Password Generator β Create strong, random passwords for every account.
- Password Strength Checker β Evaluate how secure your current passwords really are.
- File Hash Checker β Verify file integrity with SHA-256, MD5, and other hash algorithms.
Happy securing!