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

@quinnjr/qrcode-esm

v1.0.1

Published

ESM TypeScript port of qrcode

Readme

qrcode-esm

QR code generator for Node.js and the browser. Pure ESM, written in TypeScript, zero runtime dependencies.

A modernized port of qrcode.

Install

npm install @quinnjr/qrcode-esm

Usage

Node.js

import { toString, toDataURL, toBuffer, toFile } from '@quinnjr/qrcode-esm';

// Render to UTF-8 string (for terminals)
const str = await toString('https://example.com');
console.log(str);

// Render to PNG data URL
const url = await toDataURL('https://example.com');

// Render to PNG buffer
const buf = await toBuffer('https://example.com');

// Write to file (format inferred from extension: .png, .svg, .txt)
await toFile('qr.png', 'https://example.com');
await toFile('qr.svg', 'https://example.com');

Browser

import { toString, toCanvas, toDataURL } from '@quinnjr/qrcode-esm';

// Render to SVG string (default in browser)
const svg = await toString('https://example.com');

// Render to canvas
const canvas = await toCanvas('https://example.com');
document.body.appendChild(canvas);

// Render to existing canvas element
const el = document.getElementById('canvas') as HTMLCanvasElement;
await toCanvas(el, 'https://example.com');

// Render to data URL via canvas
const url = await toDataURL('https://example.com');

API

create(text, options?)

Creates QR code data without rendering. Returns a QRData object that can be passed to renderers directly.

toString(text, options?)

Returns a Promise<string>. Output format depends on the type option:

| type | Node default | Browser default | | ------------ | ------------ | --------------- | | 'utf8' | yes | | | 'terminal' | | | | 'svg' | | yes |

toDataURL(text, options?)

Returns a Promise<string> containing a data URL.

  • Node: Generates PNG, SVG, or UTF-8 data URLs depending on type.
  • Browser: Renders to a canvas and calls canvas.toDataURL().

toBuffer(text, options?) (Node only)

Returns a Promise<Buffer> containing PNG, SVG, or UTF-8 data depending on type.

toFile(path, text, options?) (Node only)

Writes a QR code to a file. Format is inferred from the file extension (.png, .svg, .txt) unless type is specified.

toCanvas(text, options?) (Browser only)

toCanvas(canvas, text, options?) (Browser only)

Renders to an HTMLCanvasElement. If no canvas is provided, one is created.

Options

interface RendererOptions {
  // QR code options
  version?: number;            // QR version (1-40), auto-detected if omitted
  errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H'; // default: 'M'
  maskPattern?: number;        // 0-7, auto-selected if omitted

  // Renderer options
  type?: string;               // 'png' | 'svg' | 'utf8' | 'terminal'
  margin?: number;             // quiet zone size in modules, default: 4
  scale?: number;              // scale factor, default: 4
  width?: number;              // output width in pixels (overrides scale)
  small?: boolean;             // use compact terminal rendering
  inverse?: boolean;           // invert colors
  color?: {
    dark?: string;             // default: '#000000ff'
    light?: string;            // default: '#ffffffff'
  };
}

Segments

For mixed-mode encoding, pass an array of segments:

await toString([
  { data: '1234', mode: 'numeric' },
  { data: 'HELLO', mode: 'alphanumeric' },
]);

License

MIT - Originally created by Ryan Day.