Numbers
TOTP Secret Key Generator
Used by developers, writers, and creators worldwide.
A TOTP secret key generator produces the Base32-encoded shared seed that connects your server to an authenticator app like Google Authenticator, Authy, or Microsoft Authenticator. When a user scans a QR code during 2FA enrollment, this string is what gets transferred — both sides then derive the same six-digit code every 30 seconds without any network call. Developers building two-factor authentication need a unique, high-entropy secret per user account. This tool generates multiple secrets at once at a length you control. The default 32 characters gives 160 bits of entropy, matching what most TOTP libraries expect and exceeding the 128-bit minimum in RFC 4226. Use these freely for development, staging, and testing — not for live production accounts.
Loading usage…
Free forever — no account required
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Set the count field to the number of secret keys you need — for example, 10 if seeding a batch of test users.
- Set the length field to your target character count; leave it at 32 for standard 160-bit TOTP compatibility.
- Click Generate to produce your Base32 secret keys as a list.
- Copy individual keys or the full list, then paste them into your database seed script, test fixture, or QR code generator.
Use Cases
- •Seeding a staging database with unique 2FA secrets for 50 test user accounts
- •Pasting a key into pyotp or otplib to verify your TOTP validation logic in unit tests
- •Populating an otpauth:// URI and QR code to test authenticator app scanning end-to-end
- •Supplying realistic Base32 secrets in API documentation and Postman collection examples
- •Generating demo secrets for a security-awareness training session on 2FA enrollment flows
Tips
- →Generate secrets at length 32 by default; only go to 64 if a specific hardware token or spec explicitly requires longer seeds.
- →Combine a generated secret with the pyotp or otplib verify function immediately — confirm the library accepts it before building enrollment logic around it.
- →When using secrets for QR code demos, pair them with a fixed account name and issuer in the otpauth URI so the authenticator app labels them clearly.
- →Generate a batch of 20-50 keys at once to populate a test-user seed file; it's faster than running the generator repeatedly for each row.
- →Never log generated secrets in console output or test reports, even in development — build that discipline early so it carries into production code.
- →If your TOTP library throws an invalid-secret error, check that you haven't accidentally included padding characters (=) — strip them before storing or passing the key.
FAQ
what length should a totp secret key be
RFC 4226 requires at least 128 bits, which is 26 Base32 characters. The de-facto standard is 32 characters (160 bits), the default here, and what Google Authenticator and most libraries like pyotp and otplib expect. Going shorter risks breaking compatibility with some authenticator apps or hardware tokens.
are these totp keys safe to use in production
No — browser-generated keys rely on a non-cryptographic random source, so they should never protect real user accounts. For production, generate secrets server-side with crypto.randomBytes(20) in Node.js or secrets.token_bytes(20) in Python, then Base32-encode the output. This tool is ideal for development, staging, demos, and test suites.
how do i turn a totp secret into a qr code for google authenticator
Format a URI as otpauth://totp/YourApp:user@example.com?secret=YOURSECRET&issuer=YourApp, then pass it to a QR code library like qrcode in Node or qrcode.js in the browser. Google Authenticator, Authy, and Microsoft Authenticator all parse this URI on scan. Paste any key from this generator directly into the secret field to test the flow.