Skip to content
codinganthem
All tools/Security/TOTP / OTP Generator

TOTP / OTP Generator

Generate RFC 6238 time-based one-time passwords (TOTP) online from a secret key. Free TOTP generator for testing 2FA flows — no sign-up needed.

30s
Click the code or use Copy code to copy the one-time password
Authenticator setup URI
otpauth://totp/CodingAnthem%3Auser%40example.com?secret=JBSWY3DPEHPK3PXP&issuer=CodingAnthem&algorithm=SHA1&digits=6&period=30

SHA-1 · 6 digits · 30s period (RFC 6238). Paste this URI into an authenticator app or QR generator.

How to test TOTP codes online

Paste a Base32 secret key, the kind shown under a 2FA QR code as "enter this key manually", and the generator shows the current 6-digit code with a countdown to the next one. Compare it with the code your app or server expects. Use Load sample to try it with a test secret.

To check an authenticator app end to end, copy the Authenticator setup URI, turn it into a QR code with the QR Code Generator, and scan it. The app and this page should show the same code.

How TOTP works

Time-based one-time passwords (RFC 6238) are built from a shared secret and the current time. The time is divided into 30-second steps, and the step number is signed with the secret using HMAC-SHA1, then cut down to 6 digits. The server does the same calculation, so the codes match without any network connection.

This generator uses SHA-1, 6 digits and a 30-second period, the defaults used by Google Authenticator and most other apps. Codes that use SHA-256, 8 digits or a 60-second period won't match.

Why codes don't match

  • The clock is off. Codes depend on the time, so a device clock more than about 30 seconds out gives different codes. Many servers accept the previous and next code to allow for small drift.
  • The secret is wrong. Base32 uses the letters A to Z and the digits 2 to 7 only, so 0, 1, 8 and 9 mean a typo. Spaces, lowercase letters and trailing = are fine; they're ignored.
  • The secret is in another format, such as hex or raw bytes, instead of Base32.
  • The settings differ: a different hash, number of digits or period.

Frequently asked questions

What is a TOTP code?+

A time-based one-time password: a short code, usually 6 digits, generated from a shared secret and the current time. It changes every 30 seconds and is used for two-factor authentication.

Why doesn't my TOTP code match?+

Usually the device clock is out of sync, the secret was copied wrongly, or the service uses different settings such as 8 digits or SHA-256. Check the clock first.

Should I paste a real 2FA secret here?+

Use test secrets. The code is generated in your browser and the secret isn't sent anywhere, but anyone who has a real secret can generate your codes, so keep real ones in your authenticator app.

Which settings does this generator support?+

SHA-1, 6 digits and a 30-second period, the standard defaults. Other algorithms, lengths and periods aren't supported.

What is an otpauth:// URI?+

The text inside a 2FA QR code. It holds the secret, the issuer, the account name and the settings, so an authenticator app can add the account in one scan.