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

bil-lbx

v0.3.1

Published

Read and write the Brother P-touch .lbx label file format

Downloads

745

Readme

bil-lbx

TypeScript library for generating and parsing Brother P-touch .lbx label files — the format used by P-touch Editor.

bil = brother-in-law: related to Brother, but not affiliated with them.

Or at least, that's what my in-laws say about me.

Works in the browser and Node (no Buffer, no filesystem APIs — image data is Uint8Array).

What's in an .lbx file

An .lbx is a ZIP archive:

| Entry | Contents | |---|---| | label.xml | Layout, objects, fonts (Brother's proprietary XML schema) | | prop.xml | Metadata (app version, timestamps) | | ObjectN.bmp | Embedded images, one per image object (optional) |

This library round-trips that archive to and from a plain-data LabelConfig object.

Install

npm install bil-lbx

Usage

Build a label

import { buildLbx, TAPE, type LabelConfig } from "bil-lbx";

const config: LabelConfig = {
  paper: {
    width: TAPE["12mm"].width,
    format: TAPE["12mm"].format,
    autoLength: true,
  },
  objects: [
    {
      type: "text",
      position: { x: 14, y: 3, width: 33, height: 26 },
      font: { name: "Helvetica", size: 12, weight: 700 },
      data: "Hello",
    },
  ],
};

const bytes: Uint8Array = await buildLbx(config);
// write to disk, or feed to a Blob for download — it's a complete .lbx file

Parse a label

import { parseLbx } from "bil-lbx";

const config = await parseLbx(bytes); // Uint8Array | ArrayBuffer
console.log(config.paper.width, config.objects.length);

Label length

Don't read paper.height directly — it only holds the length for a fixed-length label. Under autoLength P-touch parks its 1000mm ceiling (2834.4pt) there as a placeholder and records the fitted length as the extent of the printable band (style:backGround, exposed as config.background), so taking the height literally yields a 1-meter label.

import { labelLengthPt } from "bil-lbx";

const length = labelLengthPt(config); // pt, or undefined if unrecorded

backgroundFor(paper, length) builds the matching band when you're authoring a label rather than parsing one — the band is inset TAPE_MARGIN_PT (5.6pt, 2mm) from each end regardless of the paper margins.

Lower level

serializeLabel(config) returns the raw { labelXml, propXml, images } without zipping, if you need to inspect or post-process the XML.

Supported object types

  • Text — multi-line, per-run formatting, multiple fonts/weights, alignment, effects
  • Image — embedded BMP with mono-conversion settings (dither, threshold, brightness/contrast)
  • Rect — including rounded rectangles
  • Line — lines, polylines, polygons, arrowheads
  • Barcode — CODE39/128, EAN, UPC, QR, DataMatrix, PDF417, and more
  • Database — CSV mail-merge configuration

Units and tape sizes

All dimensions are in points (1pt = 1/72"). Helpers: pt(), ptVal(), mmToPt().

The TAPE constant maps standard tape widths to their point width and Brother format code:

| Tape | width (pt) | format | |---|---|---| | 3.5mm | 10 | 257 | | 6mm | 17 | 258 | | 9mm | 25.5 | 264 | | 12mm | 33.6 | 259 | | 18mm | 51 | 260 | | 24mm | 68 | 261 | | 36mm | 102 | 262 |

Format notes

  • Embedded images are always 32-bit Windows BMP — the .lbx format stores no other raster encoding. P-touch Editor rasterizes every source format (PNG, SVG, …) to BMP at import; ImageObject.originalName preserves the source filename as metadata only.
  • The ZIP uses STORE (no compression), and XML is serialized unformatted on a single line, matching Brother's own output.

Development

npm test        # vitest
npm run build   # compile to dist/

The parser suite runs against real .lbx samples committed in test/fixtures/; see test/parse.test.ts.

License

MIT