2FA Code Generator

Generate TOTP (Time-based One-Time Password) codes for two-factor authentication. Test authenticator apps or integrate 2FA into your applications.

Your TOTP Code

·
Refreshing in30s

Secret Key (Base32)

Valid characters: A-Z, 2-7. Typically 16-32 characters.

OTPAuth URL

Use this URL to generate a QR code for authenticator apps:

otpauth://totp/CodeItBro:user%40example.com?secret=&issuer=CodeItBro&digits=6&period=30

Secure Authentication Testing

Two-factor authentication adds an extra layer of security to your accounts. This tool generates standard TOTP codes that work with any RFC 6238 compliant system. Perfect for developers testing 2FA implementation or users learning how authenticator apps work.

RFC 6238 Compliant

Why Use This Generator?

Secure Generation

Cryptographically secure secret keys and TOTP codes using Web Crypto API.

Real-Time Updates

Watch the countdown and see codes refresh automatically every 30 seconds.

QR Code Ready

Generate OTPAuth URLs for QR code scanning in authenticator apps.

🔧

Configurable

Choose between 6 or 8 digit codes and custom time periods.

How this 2FA Code Generator works

This authentication testing tool generates Time-based One-Time Password (TOTP) codes following RFC 6238 specifications used by Google Authenticator, Authy, and similar applications. The generator creates cryptographically secure secret keys using the Web Crypto API, then computes HMAC-SHA1 signatures to derive 6-digit verification codes matching industry-standard 2FA implementations.

The TOTP algorithm divides time into 30-second intervals, using the current interval counter as input for HMAC computation against the base32-encoded secret key. A visual countdown progress bar shows remaining validity time before automatic code rotation, with new codes generating seamlessly at interval boundaries. Configurable options include code length (6 or 8 digits) and time period (30 or 60 seconds).

Secret key management includes visibility toggle, clipboard copy, and regeneration functions. The tool generates OTPAuth URLs compatible with QR code scanning for easy authenticator app configuration during testing. All cryptographic operations execute client-side, ensuring secret keys never transmit over networks—critical for security testing workflows while maintaining complete data privacy.

How to Use

1

Get Secret Key

Generate a new secret or enter your existing Base32-encoded key.

2

View Code

The 6 or 8-digit TOTP code updates every 30 seconds automatically.

3

Copy & Use

Copy the code before it expires and paste it in your authentication form.

Example Usage

Generating a TOTP code:

Input
Secret: JBSWY3DPEHPK3PXP
Output
Code: 284796 Refreshes: Every 30 seconds

Frequently Asked Questions

What is a 2FA TOTP code?
TOTP (Time-based One-Time Password) is a 6 or 8-digit code that changes every 30 seconds. It's used as a second factor in two-factor authentication to verify your identity.
How is the TOTP code generated?
TOTP codes are generated using HMAC-SHA1 algorithm combining your secret key with the current time. The same secret and time will always produce the same code.
What is the secret key format?
Secret keys are encoded in Base32 format, using only uppercase letters A-Z and digits 2-7. They're typically 16-32 characters long.
Can I use this for real 2FA authentication?
This tool is primarily for testing and development. For real authentication, use dedicated authenticator apps like Google Authenticator, Authy, or Microsoft Authenticator.
Is my secret key stored or transmitted?
No. All processing happens entirely in your browser. Your secret key is never sent to any server.

Related Tools

The 2FA Code Generator is maintained by CodeItBro. We aim to provide the best free developer tools on the web. If you have feedback or suggestions, please visit our contact page.

Featured on

CodeItBro - Free dev tools + practical guides to help you ship faster | Product HuntCodeItBro - Free Online Developer Tools badgeCodeItBro badge