TOTP Code Generator
2FA Codes And otpauth QR

Test two-factor codes without a phone. Paste or generate a Base32 secret and watch the live RFC 6238 code count down, check codes for any moment, and build or read otpauth:// links with a QR code. Computed with your browser's WebCrypto. 100% client-side. Zero data stored.

TOTP Code Generator illustration: the six-digit code 492 039 inside a countdown ring, next to a small QR code

TOTP Code Generator Tool

The secret stays in this tab

  • A random secret comes from crypto.getRandomValues. Every code is an HMAC computed in your browser by the open-source otpauth library (MIT), which supports TOTP and HOTP with SHA-1, SHA-256 and SHA-512. Math.random is never used.
  • The secret is never stored (no cookies, no localStorage, no URL) and never sent: this page makes no network request with it. The QR code is drawn in your browser.
  • Anyone who can see the secret or the QR code can generate your codes. Use this for development, testing and learning; for a real account, scan the code your service shows you into an authenticator app instead.

Secret and settings

Sets the published test key (the ASCII text 12345678901234567890), SHA-1, 8 digits, and the time to 59 seconds, so you can compare with the RFC.

Current code

--- --- -- s

Next code: --- ---

otpauth link and QR code

Scan with an authenticator app

Some authenticator apps ignore the algorithm, digits and period values and always use SHA-1, 6 digits and 30 seconds. Test your app before using other settings.

Codes for a chosen time

Codes for the period before, containing and after the chosen time
Period Counter Starts (Unix) Code

Check a code

Read an otpauth:// link

Common Use Cases

Test a 2FA login flow

Enroll a test account with a secret you control, then read the current code to walk through your own sign-in and recovery screens without a phone.

Provision an authenticator

Turn a Base32 secret from a server, a vault or a ticket into an otpauth link and a QR code that an authenticator app can scan.

Debug "invalid code" errors

See the codes for the periods before and after a moment, and which one a typed code matches, to tell clock drift from a wrong algorithm or digit count.

Check your own implementation

Compare your server's TOTP code with a second implementation, and use the RFC 6238 test secret to confirm a library matches the published values.

Read an old enrollment link

Paste an otpauth link from a screenshot or an export to see its issuer, account, algorithm, digits and period before you move it to a new app.

Learn how TOTP works

Change one setting at a time and watch the counter, the period start and the code change, with the same numbers the RFCs publish.

TOTP Reference

Parts of an otpauth Key URI
Part Example Meaning
otpauth://totp/otpauth://totp/The scheme and type. totp is time-based; hotp is counter-based.
labelExample:aliceIssuer and account name joined by a colon, percent-encoded. It is what the app shows.
secretJBSWY3DPEHPK3PXPRequired. The shared key in Base32 (letters A-Z and digits 2-7), without padding.
issuerExampleRecommended. The service name; it should match the label prefix.
algorithmSHA1SHA1 (default), SHA256 or SHA512. Many apps support only SHA1.
digits6Code length: 6 (default), 7 or 8. Many apps support only 6.
period30Seconds each code lasts. 30 is the default and the value apps expect.

How a code is made

The counter is the Unix time divided by the period, rounded down. The code is the HMAC of that counter under the secret, cut down to a few digits (RFC 4226 section 5.3). Both sides compute it independently, so nothing needs to be sent.

Secret length

RFC 4226 requires at least 128 bits and recommends 160 (20 bytes, 32 Base32 characters). Shorter secrets still produce codes, and some services issue 80-bit ones, but they are easier to guess. The tool tells you the size of what you paste.

Clock drift

A code depends on the clock of the phone and the server. Servers usually accept the periods just before and after the current one. If a code is rejected by one period only, check the device time first.

RFC 6238 test values

With the test secret, SHA-1 and 8 digits, Unix time 59 gives 94287082, 1111111109 gives 07081804 and 1234567890 gives 89005924. Load the test secret above to see them. The RFC uses a longer key for SHA-256 and SHA-512.

What this tool is not

It is not an authenticator app: it keeps no accounts, does not back anything up and forgets everything when you close the tab. It also cannot read a QR code; paste the otpauth link instead.

Counter-based codes

HOTP (RFC 4226) uses an event counter instead of the time. The time-based codes here are the same algorithm with the counter taken from the clock. An hotp link can be read, but only time-based codes are shown.

Frequently Asked Questions

Why We Built This TOTP Code Generator

Anyone who builds a login system ends up needing a one-time-code generator that is not their phone: to test an enrollment screen, to reproduce a bug report that says "the code is always rejected", or to hand a QA team a secret and a QR code. The usual answer is a random website that asks you to paste the secret, and that is a poor place for a secret to land.

This tool computes every code in your browser with the open-source otpauth library, takes its random secrets from the same secure generator, and says on the page which function produced each value. Nothing is stored and nothing is sent, so the worst case is the same as typing the secret into a local script. It follows RFC 4226 and RFC 6238 and reproduces their published test values, and it builds and reads the otpauth links that authenticator apps use.

The TOTP Code Generator is part of RJL.io's collection of free developer tools. For the rest of your security toolbox, try the Password Generator, the Hash Generator, the QR Code Generator and the JWT Decoder, or the Key and Token Generator for API keys and key pairs.

Is your site ready for Google and AI search?

The free SEO Analyzer checks any page in seconds - meta tags, structured data, AI crawler access - and tells you exactly how to fix each issue on your platform.