How to generate a QR code for 2FA
Create a scannable 2FA QR code from a TOTP secret and otpauth URI. Step-by-step, plus a free tool that renders one.
A 2FA QR code is just an otpauth:// URI rendered as an image. Building one means assembling the URI from your secret and settings, then encoding it as a QR your users scan. Here is how.
Build the otpauth URI
Assemble otpauth://totp/Issuer:account?secret=BASE32&issuer=Issuer with the shared secret and any non-default period, digits, or algorithm. The label (issuer and account) is what shows in the user’s authenticator app, so make it recognizable.
Render and test it
Encode that URI as a QR with any QR library, then scan it with an authenticator app to confirm the codes it produces match your server. Our TOTP tool does all of this — generates the secret, builds the otpauth URI, renders the QR, and verifies codes — so you can test the flow end to end.
Step by step
Generate or load the Base32 shared secret.
Build the otpauth://totp/... URI with issuer, account, and secret.
Render the URI as a QR code (any QR library, or our TOTP tool).
Scan it with an authenticator app and verify the code matches your server.
Try it now — free, no signup
Use the TOTP generator in your browser. Then, when you need it at scale with an API key and higher limits, grab the full Eveses API.