2FA TOTP Generator Online — Generate 2FA Codes Free
CodexFuse Team · 2026-10-15T12:34:06.465Z · 6 min read min read
A 2FA code is a password that expires. A fictional setup shows how TOTP codes are made, why a drifting clock rejects valid codes, and the setup checklist.
A 2FA code is a password that expires. It is generated from two things you already have: a secret shared between you and the service, and the current time. Because the time changes, the code changes — typically every 30 seconds — which is why a stolen code is useless minutes later.
The example below is fictional and labelled as such. It walks through one setup, one failure, and the fix, so you can see how the moving parts fit together.
The worked example: one setup, one failure, one fix
Fictional: Lena turns on two-factor authentication for her email. The service shows her a secret key, which she enters into her authenticator app. The app starts showing six-digit codes that change every 30 seconds. She enters the current code, and the service accepts it. Setup done.
A week later, a code is rejected. She tries the next code. Rejected again. The cause is not the secret — it is the clock. Her phone's time has drifted a minute behind the service's time, so the code her app generates belongs to a different 30-second window than the one the service expects. She turns on automatic time sync on her phone, waits for the next code, and it works.
That failure is the most common 2FA problem, and it has nothing to do with the password. When codes are rejected, check the clock first.
Turn on automatic date and time on every device that generates codes. A clock that drifts by a minute is the single most common reason valid codes get rejected.
How a TOTP code is made
- One shared secret. When you set up 2FA, the service gives you a secret key. Your authenticator app stores it. The service stores it too. The secret never changes, and it must never be shared.
- The current time, in 30-second steps. The app and the service both divide the current time into 30-second windows. The code is computed from the secret plus the current window.
- Six digits, one window. The result is reduced to a six-digit code. When the window passes, the code changes — even though the secret stayed the same.
The service usually accepts the code from the neighbouring window too, to allow for a few seconds of clock drift. That tolerance is why a code sometimes works a few seconds after it changes on screen — and why a clock that is a minute off still fails. Related reading: our complete guide on Move Your 2FA Codes.
What the tool does — and what it does not
The 2FA TOTP Generator tool generates time-based one-time codes from a secret key you provide. Use it when your authenticator app is unavailable and you need a code for a service you set up. It does not create the 2FA setup for you — the secret comes from the service, during setup — and it cannot recover a secret you have lost.
Enter the secret exactly as the service gave it, and make sure the device generating the code has the correct time. If the code is rejected, check the clock before assuming the secret is wrong. If you have lost the secret and the backup codes, the only path is the service's own account recovery.
Never share a TOTP secret with anyone, and never enter it on a site you did not reach yourself. A TOTP secret is a key to your account — anyone who holds it can generate your codes.
Two-factor authentication protects one account. Running a business means protecting all of them — plus hosting, email, and tools. CodexFuse runs your platform fully managed on credits, so security is not a second job.
Get Started with CodexFuseThe setup checklist
- Save the backup codes. During setup, the service shows one-time backup codes. Print them or write them down and store them somewhere safe — not in the same place as your phone. They are the way back in if you lose the authenticator.
- Save the secret. Store the secret key itself somewhere safe too, separately from the backup codes. It lets you set up a second device without going through recovery.
- Test a code before you finish. Enter one code during setup and confirm it is accepted. A setup you never tested is a setup you will discover is broken at the worst moment.
Strong authentication starts with a strong password: use a password generator rather than reusing one, and check whether an old password has appeared in a breach with the breach checker. If you must share a secret or a password with someone, use a one-time secret link — never plain chat or email.
Two-factor authentication is only half the story. Start with a strong, unique password from the password generator guide. Find hundreds more practical how-tos on our blog.
Frequently Asked Questions
Why do 2FA codes change every 30 seconds?
Because the code is computed from the secret plus the current 30-second time window. When the window passes, the code changes. A stolen code is therefore useless within a minute — which is the entire point of a one-time code.
Why is my valid code being rejected?
Most often, the clock. If your device's time has drifted from the service's time, your app generates codes for the wrong window. Turn on automatic date and time, then try the next code.
What do I do if I lose my authenticator?
Use a backup code from setup. If you saved the secret, set up a new device with it. If you have neither, use the service's account recovery — which is deliberately slow, because it is the last line of defence.
Is an authenticator app better than SMS codes?
Generally, yes. App codes are generated on your device from the secret and the time, so they cannot be intercepted in transit. SMS codes travel over the phone network, where they can be redirected by SIM-swap attacks.
Can the tool recover a lost secret?
No. The 2FA TOTP Generator tool generates codes from a secret you provide. It cannot recover a secret you have lost — only the service's backup codes or account recovery can do that.















