Skip to content

NeaByteLab/QR-Generator

Repository files navigation

QR Generator

Generate QR codes in SVG, path, GIF, PNG, ASCII, or canvas. Custom shapes, gradients, logo.

Node Deno Bun Browser

Module type: Deno/ESM npm version JSR CI License

No Logo Text Logo Variant
No Logo Text Logo Variant

Important

Generate preview assets (SVGs; GIFs if rsvg-convert is 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)
  • AccessibilitytoImgTag accepts alt (default 'QR code'); toSVG accepts optional title and alt for <title>, <desc>, role="img", and aria-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-generator

npm:

npm install @neabyte/qr-generator

Quick 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

Build & Test

From the repo root (requires Deno).

Check — format, lint, and typecheck source:

deno task check

Unit tests — format/lint tests and run all tests:

deno task test
  • Tests live under tests/ (public API in tests/qrcode.test.ts, core helpers in tests/core/*.test.ts).
  • The test task uses --allow-read for fixtures (e.g. PNG decode tests).

Reference

Attribution & Trademark

License

This project is licensed under the MIT license. See the LICENSE file for details.