QR code type
Base64 QR codes — how they work
Base64 encodes arbitrary binary as ASCII text so it can be carried in a QR code. It costs about 33% in size and forces byte mode, so use it only when the data is genuinely binary. For text, encoding directly is always smaller.
When you actually need it
Only when the payload is binary and the consuming system expects text: a small cryptographic key, a signature, a compressed blob, a protobuf message. If your data is already text, base64 makes it 33% larger for no benefit.
The size penalty compounds
Base64 turns 3 bytes into 4 characters — a 33% increase. Worse, its alphabet includes
lowercase letters, + and /, which forces the QR encoder into byte mode at 8 bits per
character.
For 300 bytes of binary:
| Encoding | Characters | QR mode | Bits |
|---|---|---|---|
| Raw bytes (if the reader accepts them) | 300 | byte | 2,400 |
| Base64 | 400 | byte | 3,200 |
| Base32 (uppercase) | 480 | alphanumeric | 2,640 |
| Base45 (uppercase) | ~366 | alphanumeric | ~2,013 |
Base32 produces more characters than base64 but encodes them at 5.5 bits instead of 8, so the code is smaller. Base45 — designed specifically for QR codes and used by the EU Digital COVID Certificate — is smaller still. If you control both ends, base45 or base32 beats base64 every time.
URL-safe base64
Standard base64 uses + and /, which must be percent-encoded inside a URL and cost
three characters each. If the base64 goes into a URL, use the URL-safe alphabet
(- and _) and strip the = padding.
Realistic capacity
At EC level M, roughly:
| Binary payload | Base64 chars | QR version | Modules |
|---|---|---|---|
| 100 bytes | 136 | 7 | 45 × 45 |
| 250 bytes | 340 | 12 | 65 × 65 |
| 500 bytes | 668 | 18 | 89 × 89 |
| 1,000 bytes | 1,336 | 26 | 121 × 121 |
Above about 500 bytes of binary you are into codes that need careful printing and a deliberate scan.
FAQ
Is base64 the best way to put binary in a QR code?
Usually not. Base32 or base45 use uppercase alphabets that the QR encoder handles in alphanumeric mode at 5.5 bits per character, producing smaller codes despite more characters.
How much does base64 add?
About 33% more characters than the raw binary, and it forces byte mode at 8 bits per character. Both effects push the code to a higher version.
Should I use URL-safe base64?
Yes, if the value goes into a URL. Standard base64's plus and slash characters need percent-encoding, costing three characters each.
What is base45?
An encoding designed specifically for QR codes, used by the EU Digital COVID Certificate. It maps binary onto the QR alphanumeric character set, giving the smallest codes of the common options.