What is a TOTP code?
A time-based one-time password (TOTP) is the six-digit code authenticator apps like Google Authenticator, Microsoft Authenticator and Authy show for two-factor login. It changes every 30 seconds and is generated from a secret shared once, when you scan the setup QR code.
Developers use a TOTP generator to test 2FA in their own apps, QA testers to log in to staging accounts, and IT admins to verify a secret was recorded correctly. This tool accepts a Base32 secret or a full otpauth link, supports 6 and 8 digits, 30 and 60-second periods and SHA-1, SHA-256 and SHA-512.
How to use the 2FA Code Generator (TOTP)
1.Paste the secret
The setup key a site shows next to its 2FA QR code, or the full otpauth:// link.
2.Check the settings
Most services use 6 digits, 30 seconds and SHA-1; links fill these in.
3.Read the code
It refreshes automatically, with the next code shown too.
Example: the RFC 6238 test vector
The standard test secret 12345678901234567890 with 8 digits at 59 seconds past the Unix epoch:
- SHA-1
- 94287082
- SHA-256 (32-byte secret)
- 46119246
- SHA-512 (64-byte secret)
- 90693936
The generator reproduces the official codes exactly, so it matches any standard authenticator app.
How the codes are made
TOTP, defined in RFC 6238, combines a shared secret with the current time. Every 30 seconds the time step changes, an HMAC of the step is computed with the secret, and a few digits are extracted. Any app with the same secret and an accurate clock produces the same code.
This page runs the calculation with the Web Crypto API and has been checked against the RFC's official test vectors. Use it for testing your own 2FA setup or as a developer tool; for real accounts, keep secrets in an authenticator app on a device you control.
Frequently asked questions
Why doesn't my code match?
Usually the device clock is off by more than a few seconds, or the digits, period or algorithm differ from the service's.
Is it safe to paste my secret here?
The secret stays in your browser, but anyone who sees it can make your codes. Only use real secrets on a trusted device.
Where do I find the secret key?
When enabling 2FA, choose "can't scan the QR code?" to reveal the text key.
Does it support Google Authenticator links?
Yes. otpauth://totp links with issuer, digits, period and algorithm are read automatically.
Related tools
Secret Key Generator
Random 128 to 512-bit keys as hex, Base64 and Base64URL.
QR Code Generator
QR codes for links, text, Wi-Fi, email, phone and SMS, as SVG or PNG.
Base64 Encoder & Decoder
Base64 and Base64url for text (UTF-8) and files.
URL Encoder & Decoder
Percent-encode or decode URLs and query values, and see a URL's parts.
JWT Decoder
Decode a JSON Web Token's header and payload and check its expiry.
Hash Generator: MD5, SHA-1, SHA-256
MD5, SHA-1 and SHA-256 hashes of text or files, with checksum compare.
More Developer tools
JSON & data
CSV tools
Network & system
Web & API
Git & releases
Encoding & security
Text & code
- Regex tester
- Text diff checker
- Cron expression explainer
- Lorem ipsum generator
- Markdown previewer
- Slug generator
- Strip HTML tags
- Unicode character inspector
- URL parser
- Markdown TOC generator
- cURL converter
- Whitespace visualizer
- Markdown link extractor
- Regex escape
- Regex match extractor
- Split text by regex
- HTML, CSS and JS playground
- Mock data generator
- Keyboard event tester
- ASCII table