Base64 Encoding: When and Why to Use It
Learn what Base64 encoding is, how it works, and when to use it. Understand the difference between encoding and encryption, common use cases, and best practices for web development.
Everything developers need to know about QR codes: data types (URL, WiFi, vCard, email), error correction levels, size optimization, and code examples for JavaScript, Python, and PHP. Free online generator included.
I used to think QR codes were a gimmick. Then COVID happened, and suddenly we were building QR menu systems for restaurant clients at Šikulovi s.r.o.. One code replaced printed menus, enabled contactless ordering, and tracked which dishes were getting attention. I went from skeptic to enthusiast in about two weeks.
QR codes are just two-dimensional barcodes - black and white squares encoding data. But the engineering behind them is clever. They can be read from any angle, work even when partially damaged, and pack a surprising amount of data into a small space. Once you understand how they work, you can make them work better.
You don't need to understand every module in a QR code, but knowing the structure helps when codes won't scan or you're trying to optimize size:
QR codes come in 40 versions (sizes). Version 1 is 21x21 modules, version 40 is 177x177. Bigger = more data, but also harder to scan. Here's the practical reality:
This is the coolest part of QR codes. They use Reed-Solomon error correction, so they work even when damaged. Higher levels mean bigger codes but better reliability. Here's how I choose:
This blew my mind when I learned it. QR codes use different encoding modes, and the mode affects size dramatically:
URLs are 90% of what I generate QR codes for. Here's what I've learned to do:
We put these in every client's office and reception area at Šikulovi s.r.o.. Visitors scan, connect, done. No more spelling out passwords. The format is specific:
WIFI:T:WPA;S:NetworkName;P:Password;;
WIFI:T:WPA;S:GuestWifi;P:welcome2024;;
WIFI:T:nopass;S:OpenNetwork;;;vCards encode contact info that saves directly to the phone. Great for business cards - scan instead of type. But keep it minimal or your QR code becomes a dense mess:
BEGIN:VCARD
VERSION:3.0
N:Doe;John;;;
FN:John Doe
TEL;TYPE=CELL:+1234567890
EMAIL:[email protected]
ORG:Acme Inc
URL:https://example.com
END:VCARDBeyond URLs and WiFi, QR codes can trigger all sorts of actions. I've used most of these at some point:
Every time I generate a QR code for print at Šikulovi s.r.o., I run through this mental checklist:
The 'qrcode' npm package handles 95% of my use cases. Simple, works everywhere, good options:
import QRCode from 'qrcode';
// Generate as data URL
QRCode.toDataURL("https://example.com", {
errorCorrectionLevel: 'M',
width: 300,
margin: 2,
color: { dark: '#000', light: '#fff' }
})
// Generate as file (Node.js)
QRCode.toFile('qr.png', 'https://example.com')Python's qrcode library is similarly simple. I use it for batch generation and server-side stuff:
pip install qrcode[pil]
import qrcode
# Quick one-liner
qrcode.make("https://example.com").save("qr.png")
# With options
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_M,
box_size=10
)
qr.add_data("https://example.com")
qr.make_image().save("qr.png")Sometimes you just need a QR code URL in an img tag. APIs work, but know the tradeoffs:
Every language has a QR library. Here's what I've used or seen recommended:
I've seen beautifully designed QR codes that nobody could scan. Print is unforgiving. Here's what actually matters:
Clients always want branded QR codes. That's fine, but there are rules:
This distinction matters more than most people realize. We've had clients print 10,000 brochures with static codes pointing to dead URLs. Don't be them.
QR codes have a dark side. Anyone can generate one pointing anywhere. I've seen phishing attacks using QR codes stuck over legitimate ones on parking meters. Be aware:
Before any QR code goes to print at Šikulovi s.r.o., we run through this:
Those restaurant QR menus we built at Šikulovi s.r.o. during COVID? They taught me that QR codes are more engineering than design. The pretty ones that marketing wanted often failed. The ugly black-and-white ones that I wanted always worked.
The formula is simple: Keep data minimal. Use appropriate error correction. Test obsessively. Dynamic for print, static for permanent. And never, ever skip that white border. Everything else is optimization.
QR codes can store up to 7,089 numeric characters, 4,296 alphanumeric characters, or 2,953 bytes of binary data. However, more data means larger codes that are harder to scan. For practical use, keep content under 500 characters.
Use URL shorteners, remove unnecessary query parameters, use uppercase URLs (enables more efficient alphanumeric encoding), choose lower error correction (L or M for screens), and avoid special characters that force byte mode encoding.
Yes, but use high error correction (H level) and keep the logo under 30% of the QR code area. Place the logo in the center, which has the least critical data. Always test extensively—logos can prevent scanning if too large.
Common issues: insufficient contrast between colors, code is too small, quiet zone (white border) is missing or too small, code is damaged or dirty, or the content is too long resulting in a dense pattern. Try increasing size and using black on white.
Static QR codes (where data is encoded directly) never expire. Dynamic QR codes that redirect through a service can expire if the service stops working. For permanent use, prefer static codes or use redirect services you control.
Use L (7%) for digital displays with short content. Use M (15%) for most printed materials. Use Q (25%) for materials that may get worn. Use H (30%) for outdoor signage, when adding logos, or harsh environments.
Yes, QR codes can be read from any rotation angle. The three finder patterns (large squares in corners) allow scanners to determine orientation automatically. However, avoid reflective surfaces and extreme angles that may cause glare.
QR codes themselves are not secure—anyone can read their contents. Never encode sensitive data like passwords or API keys directly. For sensitive applications, encode encrypted data or use QR codes only for non-sensitive identifiers.
Founder of CodeUtil. Web developer building tools I actually use. When I'm not coding, I experiment with productivity techniques (with mixed success).
Learn what Base64 encoding is, how it works, and when to use it. Understand the difference between encoding and encryption, common use cases, and best practices for web development.
I generate QR codes for everything - WiFi passwords for visitors, contact cards for business cards, URLs for print materials. Here is what I have learned about making them scan reliably.
I once spent 4 hours debugging an API call before realizing I'd used encodeURI instead of encodeURIComponent. Here's everything I learned so you don't make the same mistake.