TOTP Generator
Generate TOTP or HOTP codes in your browser from a shared secret or an otpauth:// URI.
Updated
What is the TOTP Generator?
Generate time-based one-time passwords (TOTP) in your browser from a Base32 secret or an otpauth:// URI. The tool also supports counter-based HOTP.
Your secret is processed in the page, but anyone with access to this browser profile may be able to access saved accounts. For important accounts, prefer a trusted authenticator app and do not save secrets on a shared or untrusted device. Use the algorithm, code length, and time period specified by the service; changing them can make codes invalid.
How it works
TOTP (RFC 6238) combines a shared secret with a time-step to produce a short-lived code.
1. The Shared Secret Key
At the heart of TOTP is a secret key, typically provided by a service when you enable 2FA. This key is usually presented as a QR code or a Base32 encoded string. Both the service and this generator possess this identical secret key. It's crucial to keep this key confidential, as anyone with access to it can generate your OTPs.
2. The Time Factor
Unlike traditional passwords, TOTP incorporates the current time as a critical component. The time is divided into fixed intervals, usually 30 or 60 seconds. This generator and the authenticating service both calculate a time-step value based on the current time, ensuring they are synchronized.
3. HMAC Algorithm
The secret key and the time-step value are fed into a Hash-based Message Authentication Code (HMAC) algorithm. This cryptographic function generates a unique hash. The generator supports various HMAC algorithms, including SHA-1, SHA-256, and SHA-512, providing flexibility and enhanced security options.
4. Truncation and Formatting
The resulting HMAC hash is then truncated to a shorter, fixed-length numeric code (typically 6 or 8 digits). This truncation process involves selecting a specific portion of the hash and converting it into a decimal number. Finally, the code is formatted for readability, often with a space in the middle.
5. Local Generation and Privacy
Calculations run in your browser. Saved accounts are stored in browser local storage, which is not encrypted by this tool and may be accessible to someone using the same browser profile. Avoid saving account secrets on shared or untrusted devices.
HOTP (Counter-based One-Time Password)
The tool also supports HOTP (RFC 4226), which uses a counter instead of time. Increase the counter to calculate the next code; the service and generator must stay in sync.
Examples
Generate a TOTP code from a secret key
Input a Base32 secret key to instantly generate a 6-digit time-based one-time password.
JBSWY3DPEHPK3PXPA 6-digit code such as 282 760 that rotates every 30 secondsImport a TOTP account using an otpauth URI
Paste an otpauth:// URI to automatically configure and save a new 2FA account.
otpauth://totp/Example:user@mail.com?secret=JBSWY3DPEHPK3PXP&issuer=ExampleAccount details parsed and code generated.Generate an HOTP code with a custom counter
For counter-based OTPs, manually increment the counter to generate the next valid code.
Secret: JBSWY3DPEHPK3PXP, Type: HOTP, Counter: 0282 760 — the deterministic 6-digit code for that secret at counter 0Frequently asked questions
What is TOTP?
What is TOTP?
TOTP stands for Time-based One-Time Password. It uses a shared secret and a time-step to produce a code that changes periodically. The service and authenticator must use matching settings and reasonably synchronized clocks.
How does this TOTP Generator ensure my security and privacy?
How does this TOTP Generator ensure my security and privacy?
Calculations run in your browser, and saved accounts are stored in its localStorage. Local storage is not encrypted by this tool; someone with access to the same browser profile may be able to read saved secrets. Avoid saving secrets on shared or untrusted devices.
What is an otpauth:// URI and how do I use it?
What is an otpauth:// URI and how do I use it?
An otpauth:// URI is a standardized format for encoding TOTP or HOTP account details, often presented as a QR code. You can typically scan these QR codes with an authenticator app or copy the URI string directly. This generator can parse these URIs to automatically configure your 2FA account, simplifying the setup process.
Can I use this generator offline?
Can I use this generator offline?
Yes, once the page is loaded, this TOTP Generator can function entirely offline. All necessary cryptographic calculations are performed client-side using your browser's Web Crypto API, meaning you don't need an active internet connection to generate codes after the initial page load.
What is the difference between TOTP and HOTP?
What is the difference between TOTP and HOTP?
TOTP (Time-based One-Time Password) uses the current time as a moving factor to generate codes, which expire after a short period. HOTP (HMAC-based One-Time Password) uses a counter. In this tool, you advance that counter manually; the service and generator must remain synchronized.
Why are there different algorithms like SHA-1, SHA-256, and SHA-512?
Why are there different algorithms like SHA-1, SHA-256, and SHA-512?
These are hash functions used by HMAC. The service and generator must use the same algorithm, so select the one specified by the service rather than changing it independently.
What happens if my device's clock is out of sync?
What happens if my device's clock is out of sync?
TOTP relies on time synchronization between your device and the authenticating service. If your device's clock is significantly out of sync (typically by more than 30-60 seconds), the generated codes may not be accepted. Most authenticator apps and operating systems offer options to automatically synchronize your clock to prevent this issue. This tool also provides a visual countdown to help you monitor the current time window.
How do I add or remove accounts?
How do I add or remove accounts?
You can add accounts by manually entering the secret key and other parameters, or by pasting an otpauth:// URI. Once a code is generated, you'll see an option to save the account. Saved accounts appear in the sidebar, and you can delete them individually using the trash icon next to each entry. Saved accounts are stored in this browser's local storage, which is not encrypted by the tool.
Related tools
More utilities you might find handy.
API Key Generator
Generate random strings for application secrets or testing, with selectable formats, prefixes, and bulk export.
Bcrypt Format Demo
Inspect bcrypt-like string structure and demonstrate a non-interoperable password-hash format.
CRC32 Generator
Instantly generate CRC32, CRC32C, BZIP2, MPEG-2 and other checksums for text, files, hex or Base64 – 100% client-side.