Etiket
Zero-dependency barcode & QR code SVG generator. 40+ formats, styled QR codes, tree-shakeable. Pure TypeScript.
Install / Use
/learn @productdevbook/EtiketREADME
[!IMPORTANT] Verified formats (18): QR Code, Data Matrix, PDF417, Aztec, Micro QR, rMQR, MaxiCode, MicroPDF417, Code 128, EAN-13, EAN-8, UPC-A, Code 39, Code 93, ITF, Codabar, GS1-128, Codablock F — verified with round-trip scan tests (zxing-wasm, rxing, gozxing) and/or 100% bit-match against Zint/bwip-js reference.
Experimental formats: DotCode, Han Xin, JAB Code — no open-source decoder exists for these formats. Encoders produce structurally valid output (Han Xin 75% reference match, finders 100%). PRs welcome.
Contributions welcome! If you find a scanning issue or want to improve an encoder, please open an issue or submit a PR. See Contributing below.
Quick Start
npm install etiket
import { barcode, qrcode } from "etiket";
const svg = barcode("Hello World");
const qr = qrcode("https://example.com", { dotType: "dots", ecLevel: "H" });
CLI
npx etiket qr "Hello World" -o qr.svg
npx etiket qr "Hello" --terminal
npx etiket qr "Hello" --size 300 --ec H --dot-type dots
npx etiket barcode "4006381333931" --type ean13 --show-text -o barcode.svg
npx etiket datamatrix "Hello" -o dm.svg
npx etiket pdf417 "Hello" -o pdf.svg
npx etiket aztec "Hello" -o aztec.svg
npx etiket wifi "MyNetwork" "secret123" -o wifi.svg
Tree Shaking
Import only what you need:
import { barcode } from "etiket/barcode"; // 1D barcodes only
import { qrcode } from "etiket/qr"; // QR codes only
import { datamatrix } from "etiket/datamatrix";
import { pdf417 } from "etiket/pdf417";
import { aztec } from "etiket/aztec";
Supported Formats
1D Barcodes
| Format | Type | Description |
| :----------------------- | :--------------------- | :----------------------------- |
| Code 128 | code128 | Auto charset (A/B/C) |
| Code 39 | code39 | 43-char set, optional check |
| Code 39 Ext | code39ext | Full ASCII |
| Code 93 | code93 | Higher density, 2 check digits |
| Code 93 Ext | code93ext | Full ASCII |
| EAN-13 | ean13 | Auto check digit |
| EAN-8 | ean8 | Auto check digit |
| EAN-5 | ean5 | Addon (book price) |
| EAN-2 | ean2 | Addon (issue number) |
| UPC-A | upca | 12-digit, auto check digit |
| UPC-E | upce | Compressed 8-digit |
| ITF | itf | Interleaved 2 of 5 |
| ITF-14 | itf14 | 14-digit with bearer bars |
| Codabar | codabar | Libraries, blood banks |
| MSI Plessey | msi | Mod10/11/1010/1110 |
| Pharmacode | pharmacode | Pharmaceutical |
| Code 11 | code11 | Telecommunications |
| GS1-128 | gs1-128 | AI parsing, FNC1, 100+ AIs |
| GS1 DataBar | gs1-databar | Omnidirectional, 14-digit GTIN |
| GS1 DataBar Limited | gs1-databar-limited | GTIN starting with 0/1 |
| GS1 DataBar Expanded | gs1-databar-expanded | Variable-length AI data |
| Identcode | identcode | Deutsche Post / DHL |
| Leitcode | leitcode | Deutsche Post routing |
| POSTNET | postnet | USPS legacy postal |
| PLANET | planet | USPS confirmation tracking |
| Plessey | plessey | UK library systems |
2D Codes
| Format | Function | Description |
| :----------------- | :-------------------- | :------------------------------------------ |
| QR Code | qrcode() | Versions 1-40, all EC levels, all modes |
| Micro QR | encodeMicroQR() | M1-M4 (11x11 to 17x17) |
| Data Matrix | datamatrix() | ECC 200, ASCII/C40/Text auto encoding |
| GS1 DataMatrix | gs1datamatrix() | FNC1 + AI parsing |
| PDF417 | pdf417() | Text/Byte/Numeric, 9 EC levels, ISO-8859-15 |
| MicroPDF417 | encodeMicroPDF417() | Compact PDF417 for small items |
| Aztec | aztec() | Compact + full-range, no quiet zone |
| MaxiCode | encodeMaxiCode() | 33×30 hexagonal, UPS shipping labels |
| rMQR | encodeRMQR() | Rectangular Micro QR (R7x43 to R17x139) |
| Codablock F | encodeCodablockF() | Stacked Code 128 |
| Code 16K | encodeCode16K() | Stacked barcode, 2-16 rows |
| DotCode | encodeDotCode() | Checkerboard dots, high-speed printing |
| Han Xin | encodeHanXin() | Chinese market, 84 versions, 4 finders |
| JAB Code | encodeJABCode() | Polychrome (4/8 color), ISO/IEC 23634 |
4-State Postal Barcodes
| Format | Function | Description |
| :----------------- | :---------------------- | :-------------------- |
| RM4SCC | encodeRM4SCC() | Royal Mail (UK) |
| KIX | encodeKIX() | PostNL (Netherlands) |
| Australia Post | encodeAustraliaPost() | Australia Post |
| Japan Post | encodeJapanPost() | Japan Post (Kasutama) |
| USPS IMb | encodeIMb() | Intelligent Mail (US) |
Usage
Barcodes
import { barcode } from "etiket";
barcode("Hello World"); // Code 128 (default)
barcode("4006381333931", { type: "ean13", showText: true });
barcode("00012345678905", { type: "itf14", bearerBars: true });
barcode("(01)12345678901234(17)260101", { type: "gs1-128" });
barcode("HELLO", { type: "code39", code39CheckDigit: true });
| Option | Type | Default | Description |
| :------------- | :------------------------------ | :------------ | :-------------------------- |
| type | BarcodeType | 'code128' | Barcode format |
| height | number | 80 | Bar height in pixels |
| barWidth | number | 2 | Width multiplier per module |
| color | string | '#000' | Bar color |
| background | string | '#fff' | Background color |
| showText | boolean | false | Show human-readable text |
| textPosition | 'bottom' \| 'top' | 'bottom' | Text position |
| fontSize | number | 14 | Text font size |
| fontFamily | string | 'monospace' | Text font family |
| margin | number | 10 | Margin around barcode |
| marginTop | number | margin | Top margin |
| marginBottom | number | margin | Bottom margin |
| marginLeft | number | margin | Left margin |
| marginRight | number | margin | Right margin |
| textAlign | 'center' \| 'left' \| 'right' | 'center' | Text alignment |
| rotation | 0 \| 90 \| 180 \| 270 | 0 | Barcode rotation |
| bearerBars | boolean | false | Bearer bars (ITF-14) |
| barGap | number | 0 | Extra spacing between bars |
| unit | 'px' \| 'mm' \| 'in' \| 'cm' | 'px' | Measurement unit |
| ariaLabel | string | — | SVG aria-label attribute |
| title | string | — | SVG <title> element |
| desc | string | — | SVG <desc> element |
QR Codes
import { qrcode
