Skip to content
Jellykit

TOTP Code Generator

Show live two-factor codes from a Base32 secret or otpauth:// link, and make setup QR codes for authenticator apps.

  • Runs on your device
Loading tool

About TOTP Code Generator

Paste the secret key or the otpauth:// setup link that a site gives you when you turn on two-factor authentication, and see the same six-digit codes an authenticator app would show, refreshed every second with a countdown to the next one. It is useful for checking that a new setup works, for testing a login system you are building, and for moving an account to a new app.

You can also create a fresh random secret and get a setup QR code and link for it. Everything is computed on this page with the browser’s own cryptography; the secret is not sent anywhere and is forgotten when you leave.

How it works

  1. The Base32 secret is decoded to bytes. Spaces, hyphens, lower case and trailing = padding are accepted, as apps display them in different ways.
  2. The current time in seconds is divided by the period (30 by default) to get a counter, which is signed with HMAC-SHA1, SHA-256 or SHA-512 through the Web Crypto API, as RFC 6238 describes.
  3. Four bytes of the signature are picked out and reduced to 6, 7 or 8 digits. The results match the published RFC 4226 and RFC 6238 test values.
  4. A pasted otpauth:// link supplies its own algorithm, digit count and period. The setup QR code encodes the link in the Key Uri Format that authenticator apps scan.

Questions

Why does my code not match my phone?

TOTP depends on the clock. If this device’s clock is more than a few seconds off, the codes drift. Also check that the algorithm, digits and period match what the site specified; most sites use SHA1, 6 digits and 30 seconds.

Is it safe to paste my secret here?

The secret stays in this page’s memory and is never sent, stored or put in the address bar. Still, anyone who has the secret can produce your codes, so only paste it on a device you trust and clear it when you are done.

Can I use this instead of an authenticator app?

It is meant for setting up, testing and checking. Because it forgets the secret when you close the page, it is not a replacement for an app that keeps your accounts safely stored.

Do all apps honour SHA256, 8 digits or a 60-second period?

No. Several popular apps ignore those settings and always use SHA1, 6 digits and 30 seconds. Use the defaults unless the service you are setting up asks for something else.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.