qr-encode Generate a QR code as SVG from text
Flags
--ecl select: L | M | Q | H default: M
--margin number default: 4
--width number default: 0
Examples
Generate a QR code for a website URL
Usage
"https://pipr.tools" | qr-encode Create a QR code for a promotional campaign link
Usage
"https://shop.example.com/promo?code=SUMMER25" | qr-encode Generate a QR code for WiFi login at an event
Usage
"WIFI:S:OfficeGuest;T:WPA;P:welcome2025;;" | qr-encode View source
async (input, opts = {})=>{
if (!input.trim()) return "";
try {
const { default: QRCode } = await import('qrcode').then(async (m)=>{
await m.__tla;
return m;
});
const qrOpts = {
type: "svg",
errorCorrectionLevel: opts.ecl || "M",
margin: parseInt(opts.margin) || 4
};
const w = parseInt(opts.width);
if (w > 0) qrOpts.width = w;
return await QRCode.toString(input, qrOpts);
} catch (e) {
return `Error: ${e.message}`;
}
}