What is a 2FA code?

A two-factor authentication (2FA) code is a short-lived verification code used alongside your password. Many authenticator apps and websites create six-digit codes using TOTP, the Time-Based One-Time Password algorithm.

Open the free 2FA code generator

How TOTP codes work

TOTP combines a shared secret with the current time to calculate a one-time password. The account service and authenticator independently calculate the code from the same secret and time window. The method is specified in IETF RFC 6238; 30 seconds is its default time step.

A setup key is not the same as the six-digit code. The key is the long-lived secret used to calculate many temporary codes. Keep the setup key private: anyone who obtains it may be able to generate codes for that account.

How to generate a 2FA code

  1. Open the security or two-step verification settings for the account you are setting up.
  2. Choose an authenticator app if offered, then reveal or copy the manual setup key. This tool accepts a Base32 TOTP key; it does not scan QR codes.
  3. Paste the setup key into the 2FA code generator. A valid key starts code generation automatically.
  4. Copy the current six-digit code into the account’s verification field before it expires.

What this online TOTP generator supports

This browser tool generates six-digit TOTP codes using SHA-1 and a 30-second period. It accepts a Base32 secret, refreshes the code as time advances, and lets you copy the current code. It does not generate SMS codes, counter-based HOTP codes, or codes from a QR image.

Why a 2FA code may not work

  • Check the device clock. TOTP depends on time; enable automatic date and time if the code is rejected.
  • Check the setup key. A missing or incorrect character produces a different code.
  • Use a fresh code. Wait for the next code if the current one is about to expire, then enter it promptly.
  • Confirm the account’s method. Some services use SMS, passkeys, or HOTP instead of TOTP.

Is it safe to enter a 2FA setup key online?

A TOTP setup key is a credential and should be protected like a password. This tool saves the entered key in this browser’s local storage so it can restore the generator later. This website also loads third-party advertising scripts, which execute in the page. For important accounts, use a dedicated authenticator you trust rather than entering the setup key on an ad-supported page.

Never send a setup key or one-time code to another person. Use the account provider’s official recovery process if you lose access to your authenticator.

Frequently asked questions about 2FA codes

How long is a TOTP code valid?

This generator uses a 30-second time step. Services may allow a small time tolerance, but enter the current code promptly.

Can I use a TOTP generator without internet?

The TOTP calculation itself uses the saved secret and device time, not a network request. This site’s first load and third-party ads require an internet connection; an installed, previously loaded app may keep its core files available offline.

Does 2FA mean the same thing as TOTP?

No. Two-factor authentication describes using a second verification factor. TOTP is one method for producing codes that can serve as that second factor.