@neabyte/qr-generator
v0.2.2
Published
QR code SVG generator with custom shapes, gradients, logo
Maintainers
Readme
QR Generator
Generate QR codes in SVG, path, GIF, PNG, ASCII, or canvas. Custom shapes, gradients, logo.
| No Logo | Text Logo | Variant |
| :--------------------------------------: | :------------------------------------------: | :--------------------------------------: |
|
|
|
|
[!IMPORTANT] Generate preview assets (SVGs; GIFs if
rsvg-convertis installed):deno run -A preview/generator.ts
Features
- Multiple output formats
- ASCII art (
toASCII) - Canvas rendering (
toCanvas) - GIF data URL (
toDataURL) - PNG data URL (
toPNG) - Raw path data (
toPath) - SVG string (
toSVG) - Table/img HTML (
toTableTag,toImgTag)
- ASCII art (
- Accessibility —
toImgTagacceptsalt(default'QR code');toSVGaccepts optionaltitleandaltfor<title>,<desc>,role="img", andaria-labelledby. - Finder pattern styling — Separate shape and gap for the three corner finder patterns.
- Custom module shapes — Rounded, circle, diamond, square, shuriken, star, triangle; configurable gap.
- Color options — Solid color or linear/radial gradients with full control over stops and geometry.
- Center logo — Text or image overlay with size and corner radius; SVG output escapes attributes.
Installation
[!NOTE] Prerequisites: For Deno (install from deno.com). For npm use Node.js (e.g. nodejs.org).
Deno (JSR):
deno add jsr:@neabyte/qr-generatornpm:
npm install @neabyte/qr-generatorQuick Start
Pass value (text or URL) and size (width/height in px). You get an SVG string.
import QRCode from '@neabyte/qr-generator'
const svg = QRCode.toSVG({
value: 'https://neabyte.com/',
size: 400,
color: '#000000',
background: '#ffffff'
})
// Use in HTML, save to file, or return from API- USAGE.md for all options (shapes, gradients, logo,
toPath, etc.). - examples/README.md for runnable scripts.
Build & Test
From the repo root (requires Deno).
Check — format, lint, and typecheck source:
deno task checkUnit tests — format/lint tests and run all tests:
deno task test- Tests live under
tests/(public API intests/qrcode.test.ts, core helpers intests/core/*.test.ts). - The test task uses
--allow-readfor fixtures (e.g. PNG decode tests).
Reference
- Portable Network Graphics (PNG) Specification — W3C PNG (Third Edition); used for PNG decode in core
- SVG path
dattribute — MDN tutorial on path syntax (fortoPath()output) - react-native-qrcode-skia — React Native QRCode Skia
Attribution & Trademark
This library is based on qrcode-generator by Kazuhiko Arase (MIT).
The implementation follows JIS X 0510:1999. The word "QR Code" is a registered trademark of DENSO WAVE INCORPORATED. See: FAQ on QR Code patents/trademarks.
License
This project is licensed under the MIT license. See the LICENSE file for details.
