npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

qrcode-caption

v0.4.0

Published

Wrapper around the qrcode lib to generate QR codes with a caption

Readme

qrcode-caption

qrcode-caption is a Node.js library that extends the functionality of the qrcode package, enabling users to generate QR codes with customizable captions.

Features

  • Generate QR codes with embedded captions.
  • Customize caption text, and font size.
  • Support for various output formats (SVG, PNG, JPEG, WEBP)

Installation

You can include qrcode-caption in your project using one of the following methods:

Install via npm

To use qrcode-caption with Node.js or as part of your frontend code, install it via npm:

npm install qrcode-caption

Include via a <script> tag

To use qrcode-caption directly in a browser, include the bundled version via a <script> tag from a CDN:

<script src="https://cdn.jsdelivr.net/npm/qrcode-caption@latest/dist/bundle.min.js"></script>

This makes the library available globally as QRCodeCaption, allowing you to generate QR codes with captions in browser environments.

Usage

In Node.js / bundled environment

import { toDataURL, toSVG } from "qrcode-caption";

// or const { toSVG, toDataURL } = require("qrcode-caption");

// Generate a QR code SVG with caption
const qrCode = toSVG("https://example.com", "Scan to visit example.com");

// Generate a QR code as Data URL
const dataUrl = toDataURL("https://example.com", "Scan to visit example.com");

In browser with script tag

<div id="qrcode"></div>
<img id="qrcode-img" />
<script>
  // Generate QR code SVG and insert into page
  document.getElementById("qrcode").innerHTML = QRCodeCaption.toSVG("https://example.com", "Scan to visit example.com");

  // Generate QR code as Data URL and set as image source
  document.getElementById("qrcode-img").src = QRCodeCaption.toDataURL(
    "https://example.com",
    "Scan to visit example.com",
  );
</script>

Options

version?: number

Specifies the QR Code version (1–40). If omitted, the library automatically selects the smallest version that fits the encoded data.

errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H'

Defines the error-correction level. Higher levels allow more damage correction but reduce capacity.

| Level | Error Correction | Typical Use | | ----- | ---------------- | ------------------ | | L | ~7% | Max capacity | | M | ~15% (default) | Standard | | Q | ~25% | Higher reliability | | H | ~30% | Harsh conditions |

Default: 'M'

maskPattern?: number

Forces the mask pattern (0–7). If omitted, the best-performing mask is chosen automatically.

toSJISFunc?: QRCodeToSJISFunc

A function that converts Kanji characters to their Shift-JIS values. Provide this if you need Kanji encoding mode support. If not using Kanji mode, this option can be ignored.

margin?: Percentage | number | null

SVG-specific override of the quiet zone. Accepts:

  • pixel values (20)
  • percentages ("10%")
  • null to remove or rely on defaults.

Default: 4

scale?: number

Scales the output. A value of 1 renders each QR module as 1 pixel.

Default: 4

width?: number

Forces an explicit output width (in pixels). This option overrides scale.

color?: { foreground?: string; background?: string }

Defines QR code colors in 8-digit hex RGBA format.

  • foreground — Color of the dark modules Default: '#000000ff'
  • background — Color of the light modules Default: '#ffffffff'

fontSize?: Percentage | number | null

Font size for embedded SVG text or labels. Supports:

  • numeric pixels (12)
  • percentage strings ("150%")
  • null to omit font sizing.

Accessibility Attributes

These optional ARIA attributes can help your SVG QR code be screen-reader friendly.

"aria-label"?: string

Provides a readable text description (e.g., the encoded URL or a human-friendly message).

"aria-labelledby"?: string

References the id of another element whose text serves as the label.

"aria-hidden"?: boolean

If true, hides the QR code from assistive technologies. Useful when the QR code is purely decorative.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request. For major changes, open an issue first to discuss what you would like to change.

License

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