Free 2FA Code Generator (TOTP Authenticator)

Free online 2FA code generator. Paste a secret key to get time-based codes, check a code from your app, and make a secret with a QR code. It runs in your browser, so nothing is uploaded.

2FA Code Generator by Utiliby

Free 2FA Code Generator (TOTP Authenticator)

Generate time-based one-time passcodes from a secret key, check codes, make a secret and a QR code. Runs in your browser.

Clock settings

Codes depend on the time. Use the offset if your device clock is a few seconds off, or set a fixed Unix time to test.

Disclaimer: This free 2FA code generator runs in your browser, so the secret key is not uploaded or stored. Treat the secret like a password: anyone who has it can generate your login codes. For important accounts, keep your codes in a trusted authenticator app on a device you control, and keep the backup codes the service gives you. Do not paste the secret of an account you cannot recover into any website you do not trust. This tool is for learning, testing, recovery of your own codes and developer work, and it is not a replacement for a dedicated authenticator app.

Share, cite or embed this tool

Written by the Utiliby editorial team · Last updated October 14, 2026 · Rules and formulas reviewed October 2026

What this free 2FA code generator does

Two-factor authentication adds a second step to a login: after your password, you type a short code that changes every 30 seconds. Those codes come from an app on your phone, and they are made from a secret key that you and the service share. This free online 2FA code generator does the same job in your browser. Paste the secret or the setup link, and it shows the current code, the next code and how many seconds are left.

It also helps you to check a code from your own app, find clock problems, make a new random secret, build the setup link and draw a QR code that an authenticator app can scan. It supports SHA-1, SHA-256 and SHA-512, 6 to 8 digits and 15, 30 or 60-second periods, so it works with nearly every service.

How a time-based code is made Shared secret Time ÷ 30 s HMAC → 6 digits 482 913 A new code every 30 seconds, made on both sides without sending the secret again.
Your phone and the website each compute the code from the same secret and the same clock, so they agree without talking to each other.

How to use the 2FA code generator

  1. Paste your secret. Use the Base32 text the service shows during setup, or a full otpauth:// link. Spaces are fine.
  2. Read the code. The big number is the current code. Press it to copy.
  3. Watch the bar. When it runs out, a new code starts. The next code is shown ahead of time.
  4. Check an app code. Enter the code your authenticator shows, and the tool tells you whether it matches.
  5. Set up a new key. Make a random secret, scan the QR code with an app and enter a code on the service to finish.

How time-based codes work

During setup, a service creates a random secret and shares it with you, usually as a QR code. Your authenticator stores it. Every 30 seconds both sides compute HMAC(secret, time ÷ 30), take a piece of the result called the dynamic truncation, and turn it into six digits. Because the secret and the clock are the same, the codes match. The secret never needs to be sent again, and an old code is useless once its window passes.

The algorithm is defined in RFC 4226 for counters and RFC 6238 for time. This tool follows both and matches the published test values.

SettingUsual valueMeaning
AlgorithmSHA-1The hash inside HMAC
Digits6Length of the code
Period30 secondsHow long a code is valid

Why a code is rejected

The check box shows if your code matches a nearby step, which is the sign of clock drift, and the time offset setting lets you correct for it.

Keeping your two-factor codes safe

The secret key is as valuable as a password, because it makes every future code. Store it in a password manager or in the secure storage of an authenticator app, never in a note called 2FA. Keep the backup codes that services give you in a separate safe place, since they let you in when your phone is lost. Avoid sharing a screenshot of the QR code. Where possible choose an app or a hardware key over text message codes, which can be intercepted through SIM swapping.

For developers and testers

Developers can use the tool to test sign-in flows and to create test secrets. The RFC example button loads the standard 20-byte secret 12345678901234567890 in Base32 at time 59 with 8 digits, which must give 94287082. The fixed time box lets you reproduce any moment, and the verify box shows how a server with a one-step window would react. For production code use a vetted library, store secrets encrypted, limit attempts and never log codes.

What two-factor codes do not protect against

Time-based codes stop password-only attacks, but a fake login page can ask for the code and use it at once, which is called a real-time phishing attack. Hardware keys and passkeys resist that. Codes also do not help if malware controls your device. Treat two-factor authentication as a strong layer, not the only one, and keep your software up to date.

Setting up two-factor authentication step by step

  1. Open the security settings of your account and choose an authenticator app as the second step.
  2. The service shows a QR code and a text secret. Scan the code with an authenticator app, or paste the text secret into this tool.
  3. Enter the six-digit code to prove it works.
  4. Save the backup codes in a safe place. They let you in if the phone is lost.
  5. Record the secret in a password manager that you trust, so you can restore the codes on a new device.

If a service offers a hardware security key or a passkey, those resist phishing better than codes and are worth adding as well.

Planning for a lost phone

The most common two-factor problem is not an attack but a lost or replaced phone. Before it happens, keep at least one recovery path for each important account: the backup codes, a second authenticator that holds the same secret, a hardware key or a recovery email address that has its own protection. Some authenticator apps back up their accounts to the cloud, which helps convenience but adds a place to protect with a strong password. Test your recovery path once, since a method you have never used may not work when you need it. Remove the secret from any place that you do not control once you have stored it safely.

Privacy, limits and responsible use

The secret, the settings and the codes are used only in this page and are not sent or saved. The printed and downloaded summaries hide the secret. Use the tool for your own accounts and for testing. Do not use it to access an account that is not yours.

Frequently asked questions

What is a 2FA code generator?

It creates the 6-digit time-based codes used for two-factor authentication. The codes come from a secret key and the current time, the same way an authenticator app makes them.

How do I use this tool?

Paste the Base32 secret key, or a full otpauth:// setup link, and the current code appears. A bar shows how long it stays valid.

Where do I find my secret key?

Services show it as text next to the QR code when you set up two-factor authentication, often under a link such as Can't scan the code. Save it somewhere safe when you set up.

Is it safe to enter my secret here?

The secret stays in your browser and is not uploaded or saved. Even so, treat it like a password and use a trusted authenticator app for important accounts.

What is TOTP?

Time-based One-Time Password, defined in RFC 6238. It turns a shared secret and the current 30-second window into a short code.

Why is my code not accepted?

Common causes are a wrong secret, a device clock that is off, the wrong algorithm, digits or period, or typing the code just as it changes. Use the check box and the time offset to find the cause.

What if my clock is wrong?

Services accept small drift, but a clock off by a minute or more fails. Fix the device time automatically, or use the offset to line up with the server.

What are the algorithm, digits and period options?

Most services use SHA-1, 6 digits and 30 seconds. Change them only if the service or the setup link says so.

Can I generate a new secret?

Yes. The random secret button makes a 160-bit key. Add the same key to the service and to your authenticator, and keep a copy in a safe place.

What is the QR code for?

It holds the setup link, so an authenticator app can add the account by scanning instead of typing the secret.

Can I move codes to a new phone?

Yes, if you kept the secret key or the QR code from setup. Otherwise use the service's backup codes or recovery process.

Does this replace an authenticator app?

No. A dedicated app keeps secrets in secure device storage. This tool is for testing, learning, development and recovering your own codes.

How does the check box work?

Enter the code from your app. The tool tells you if it matches now, or if it matches one step before or after, which points to clock drift.

What is the RFC test example?

It loads the sample secret and time from the standard, so you can see that this tool gives the published answer of 94287082.

Is two-factor authentication really necessary?

It is one of the best protections available. It stops most account takeovers even when a password leaks. App codes are safer than text messages.

What does the print option include?

A settings summary with a masked secret. It never includes the full secret, the setup link or the live code.

Is it free?

Yes. It is free to use online with no sign-up.

Sources and further reading

Sources were consulted in October 2026. Standards and rules can change, so always check the official page for your situation.

Disclaimer: This free 2FA code generator runs in your browser, so the secret key is not uploaded or stored. Treat the secret like a password: anyone who has it can generate your login codes. For important accounts, keep your codes in a trusted authenticator app on a device you control, and keep the backup codes the service gives you. Do not paste the secret of an account you cannot recover into any website you do not trust. This tool is for learning, testing, recovery of your own codes and developer work, and it is not a replacement for a dedicated authenticator app.