qrlogo-generator
v1.1.0
Published
Generate QR codes as SVG with embedded SVG logo support
Maintainers
Readme
qrlogo-generator
Generate QR codes as SVG with an embedded SVG logo. Zero heavy dependencies.
Installation
npm install qrlogo-generatorUsage
import { generateQRCodeSVG } from "qrlogo-generator"
const logo = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<circle cx="50" cy="50" r="40" fill="#e94560"/>
</svg>`
const svg = generateQRCodeSVG({
url: "https://example.com",
svgContent: logo,
size: 400,
moduleColor: "#1a1a2e",
finderColor: "#e94560",
backgroundColor: "transparent",
errorCorrectionLevel: "H",
})The returned svg is a string you can write to a file, inject into the DOM, or use as an HTTP response.
API
generateQRCodeSVG(options): string
| Option | Type | Default | Description |
|---|---|---|---|
| url | string | required | Text or URL to encode |
| svgContent | string | required | SVG string to embed as logo (must be valid SVG) |
| size | number | 300 | Output SVG size in pixels |
| moduleColor | string | "#000000" | Color of QR data modules |
| finderColor | string | "#000000" | Color of finder patterns |
| backgroundColor | string | "#ffffff" | Background color ("transparent" for no background) |
| errorCorrectionLevel | "L" \| "M" \| "Q" \| "H" | "H" | Error correction level |
Note: Only SVG format is accepted for the logo. Passing non-SVG content will throw an error.
Output
A self-contained SVG string with:
- QR code data modules
- Finder patterns with custom color
- Embedded SVG logo in the center
- Configurable background (solid color or transparent)
Works in browsers and Node.js.
License
MIT
