When a guest scans a Wi-Fi QR code and their phone says "Join CafeGuest?", there is no app, no link and no server involved. The QR code holds one short line of plain text, and the phone's camera knows how to read it.
Once you know that line, you can generate Wi-Fi codes from any language with any QR library.
The format
WIFI:T:WPA;S:CafeGuest;P:welcome2026;; | Field | Meaning | Values |
|---|---|---|
T: | Security type | WPA (covers WPA/WPA2/most WPA3), WEP, or nopass |
S: | Network name (SSID) | Case-sensitive |
P: | Password | Leave out for nopass |
H: | Hidden network | true only if the SSID is not broadcast |
Each field ends with ; and the whole string ends with an extra ;, which is why it finishes with ;;.
The part everyone gets wrong: escaping
What happens if your password is pass;word? The phone reads P:pass, sees the ;, and thinks the password field is over. The guest gets a vague "could not join" error.
The special characters \, ;, ,, : and " must be escaped with a backslash, in both the SSID and the password:
function escapeWifi(value) { return value.replace(/([\\;,:"])/g, '\\$1'); } function wifiPayload({ ssid, password = '', type = 'WPA', hidden = false }) { let s = `WIFI:T:${type};S:${escapeWifi(ssid)};`; if (type !== 'nopass') s += `P:${escapeWifi(password)};`; if (hidden) s += 'H:true;'; return s + ';'; } wifiPayload({ ssid: 'Cafe;Guest', password: 'a:b,c' }); // WIFI:T:WPA;S:Cafe\;Guest;P:a\:b\,c;; Note that the backslash itself goes first in the character class, so it is escaped too.
Turn it into a QR code
With the qrcode package:
import QRCode from 'qrcode'; const text = wifiPayload({ ssid: 'CafeGuest', password: 'welcome2026' }); // In the browser: show it in an <img> const dataUrl = await QRCode.toDataURL(text, { errorCorrectionLevel: 'M', margin: 4, width: 512, }); document.querySelector('#wifi-qr').src = dataUrl; // Or get an SVG string for printing const svg = await QRCode.toString(text, { type: 'svg' }); Keep the quiet zone (margin: 4). Codes printed edge-to-edge on a table card are the ones phones struggle with.
Things to check before you print it
- Test while disconnected. Forget the network on your phone, then scan. If it joins, the code is right.
- Copy the SSID exactly.
CafeGuestandcafeguestare different networks, and a trailing space counts. - The password is plain text inside the code. Anyone who photographs it can read it with any scanner app. Put a guest network in the code, not the one your POS or cameras use.
- WPA-Enterprise won't work. Networks that ask for a username can't be joined with a standard Wi-Fi QR code.
- Changing the password breaks the code. It's a static code, so print a new one.
Modern iPhones (iOS 11+) and most Android phones (Android 10+) read these straight from the camera app.
No-code version
If you just need one for a café table or an Airbnb, we built a free Wi-Fi QR code generator that handles the escaping, shows a scan score, and exports PNG or SVG. It runs in the browser, so the password never goes to a server.
Have you hit any phone that refuses to read these? I'd like to collect the edge cases.


