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

@bobfrankston/brother-label

v1.0.14

Published

API and CLI for printing labels on Brother P-touch printers

Downloads

56

Readme

@bobfrankston/brother-label

Print labels to Brother P-touch label printers from Node.js. Supports text, HTML, images, and QR codes.

Installation

npm install - @bobfrankston/brother-label

Command Line Usage

Print text

brother-print print "Hello World"
brother-print print "Line 1\\nLine 2"  # Multi-line

Print QR code

brother-print qr "https://example.com"
brother-print qr "https://example.com" -l "My Site"  # With text label
brother-print qr "any data" -o qr.png                # Save to file

Print HTML

brother-print html label.html

Inline QR codes in HTML

Use <img qr="data"> to embed QR codes directly in HTML - they're converted to base64 at render time:

<img qr="https://example.com" style="width:10mm; height:10mm">
<img qr="any data here" class="my-qr">

Multi-segment labels

Combine multiple -text and -qr segments on a single label, printed side-by-side in order:

brother-print -text "Hello" -qr "https://example.com"
brother-print -text "Top\nBottom" -qr "https://example.com" -text "More text"
brother-print -t "Label" -q "data" -o combined.png

Print image

brother-print image photo.png

Preview (save without printing)

brother-print preview "Test Label" -o preview.png

Configuration

brother-print config --show              # Show current config
brother-print config -s 12               # Set default tape size
brother-print config -p "Brother PT-P710BT"  # Set default printer
brother-print list                       # List Brother printers

Options

| Option | Description | |--------|-------------| | -t, --text | Force input as literal text; repeatable for multi-segment labels | | -q, --qr | QR code segment; repeatable for multi-segment labels | | -s, --tape <size> | Tape size: 6, 9, 12, 18, 24 (mm) | | -p, --printer <name> | Printer name | | -o, --output <file> | Save to file instead of printing | | -a, --aspect <ratio> | Aspect ratio width:height for HTML (e.g., 3.5:2) | | -H, --height <size> | Text height: 12mm, .5in, or 50% (of tape height) | | -w, --html | Force input as HTML file path | | -i, --image | Force input as image file path |

Single-hyphen long options are supported: -text works the same as --text, -tape as --tape, etc. Single letters are strict: -t means --text, not the start of -tape.

API Usage

Print text

import { print } from "@bobfrankston/brother-label";

await print({ text: "Hello World" });
await print({ text: "Hello", tape: 12 });  // 12mm tape

Print QR code

import { print, render } from "@bobfrankston/brother-label";

// Print QR code
await print({ qr: "https://example.com" });

// QR code with text label
await print({ qr: "https://example.com", qrLabel: "My Site" });

// Render to buffer without printing
const buffer = await render({ qr: "https://example.com" });

Print HTML

// From file
await print({ htmlPath: "label.html" });

// Inline HTML
await print({
    html: "<div style='font-size:24px'>Hello</div>",
    basePath: __dirname  // For resolving relative resources
});

// With aspect ratio
await print({ htmlPath: "label.html", aspect: "4:1" });

// HTML with inline QR codes - <img qr="..."> auto-converted to base64
await print({
    html: `<img qr="https://example.com" style="width:10mm">`,
});

Print image

// From file
await print({ imagePath: "photo.png" });

// From buffer
await print({ imageBuffer: fs.readFileSync("photo.png") });

Configuration

import { getConfig, setConfig, listPrinters } from "@bobfrankston/brother-label";

// Get current config
const config = getConfig();
console.log(config.defaultTape);    // 12
console.log(config.defaultPrinter); // "Brother PT-P710BT"

// Set defaults
setConfig({ defaultTape: 24, defaultPrinter: "Brother PT-P710BT" });

// List printers
const printers = await listPrinters();
printers.forEach(p => console.log(p.name));

Render without printing

import { render } from "@bobfrankston/brother-label";

const buffer = await render({ text: "Hello" });
fs.writeFileSync("label.png", buffer);

API Reference

Types

type TapeSize = 6 | 9 | 12 | 18 | 24;

interface PrintOptions {
    // Content (exactly one required)
    text?: string;           // Plain text
    html?: string;           // Inline HTML
    htmlPath?: string;       // Path to HTML file
    textFile?: string;       // Path to text file
    imagePath?: string;      // Path to image file
    imageBuffer?: Buffer;    // Image buffer
    qr?: string;             // QR code data

    // Settings
    tape?: TapeSize;         // Tape size in mm
    printer?: string;        // Printer name
    basePath?: string;       // Base path for HTML resources
    aspect?: string;         // Aspect ratio for HTML (e.g., "4:1")
    qrLabel?: string;        // Text label beside QR code
}

interface PrintResult {
    image: Buffer;           // The rendered image
}

Functions

| Function | Description | |----------|-------------| | print(options) | Render and print a label | | render(options) | Render label to PNG buffer | | renderSegments(segments, tape?, textHeight?) | Render multiple text/qr segments side-by-side | | printSegments(segments, options?) | Render and print multiple segments | | getConfig() | Get current configuration | | setConfig(config) | Set default tape/printer | | getConfigPath() | Get config file path | | listPrinters() | List Brother printers |

Supported Printers

  • Brother PT-P710BT (tested)
  • Other Brother P-touch printers (should work)
  • Brother QL series (untested)

Requirements

  • Windows (uses Windows printing APIs)
  • Node.js 20+
  • Puppeteer (for HTML rendering)