All Tools / Blog / How to Generate a QR Code (Free)

How to Generate a QR Code (Free)

3 min read

QR codes encode text as a 2D pattern that phone cameras read without any app. Most people use them for URLs, but they work for WiFi credentials, contact cards, email addresses, phone numbers, and plain text. Here's how to generate them.

In the browser

Paste text or a URL into the QR code generator and download the result. The tool runs entirely in the browser — nothing gets sent to a server.

For print: download at 1000×1000 px or larger. For digital use (website, presentation): 300×300 px is enough.

What you can encode

Content type Format to enter
URL https://example.com
Plain text Any text string
Email mailto:user@example.com
Phone number tel:+6281234567890
SMS SMSTO:+6281234567890:Your message
WiFi WIFI:T:WPA;S:NetworkName;P:password;;
Location geo:-6.2088,106.8456
vCard (contact) BEGIN:VCARD...END:VCARD

WiFi QR codes are the most practical — guests scan to join without reading out a password.

Python: qrcode

pip install qrcode[pil]
import qrcode

# Basic URL
qr = qrcode.make("https://example.com")
qr.save("qr.png")

With custom error correction and size:

import qrcode
from qrcode.constants import ERROR_CORRECT_H

qr = qrcode.QRCode(
    version=None,                       # auto-size
    error_correction=ERROR_CORRECT_H,   # 30% damage recovery
    box_size=10,                        # pixels per module
    border=4,                           # quiet zone width (modules)
)
qr.add_data("https://example.com")
qr.make(fit=True)

img = qr.make_image(fill_color="black", back_color="white")
img.save("qr.png")

Error correction levels control how much of the code can be damaged and still scan:

Level Max damage When to use
L 7% Clean digital screens
M 15% General purpose
Q 25% Slightly worn surfaces
H 30% Print on physical objects

JavaScript: qrcode

npm install qrcode
const QRCode = require('qrcode');

// Save as PNG file
QRCode.toFile('qr.png', 'https://example.com', { width: 300 }, err => {
    if (err) throw err;
});

// Get as data URL (for embedding in HTML/email)
const url = await QRCode.toDataURL('https://example.com', { width: 300 });
// url = "data:image/png;base64,..."

// Get as SVG string (best for print)
const svg = await QRCode.toString('https://example.com', { type: 'svg' });
require('fs').writeFileSync('qr.svg', svg);

Use SVG for print materials — it scales to any size without pixelation.

WiFi QR format

The full format:

WIFI:T:WPA;S:MyNetwork;P:MyPassword123;;

Fields:

  • T: Security type (WPA, WEP, or empty for open networks)
  • S: SSID (the network name, case-sensitive)
  • P: Password
  • H:true optional — add if the network is hidden

Android and iOS cameras scan this natively. No app required.

QR code size and scanning distance

A code that's too small won't scan reliably in poor lighting or at an angle.

Printed size Reliable scanning distance
2 × 2 cm Up to 20 cm
4 × 4 cm Up to 40 cm
8 × 8 cm Up to 80 cm
20 × 20 cm Up to 2 m

The general rule: scanning distance is about 10× the printed size. A QR code on a poster needs to be far larger than one on a business card.

Key takeaways

  • URLs, WiFi credentials, contact cards, and plain text all encode into standard QR codes.
  • Use SVG output for print materials — it scales without pixelation.
  • Error correction H (30% recovery) for physical print; L for digital-only.
  • WiFi format: WIFI:T:WPA;S:NetworkName;P:password;;
  • Scanning distance is roughly 10× the printed code size.