GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Labelixa/zpl-examples: Working, tested Zebra ZPL label examples — shipping labels, barcodes, QR — with curl/Python/Node/C# integration snippets.

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
.devcontainer
.devcontainer
 
 
examples
examples
 
 
integrations
integrations
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

ZPL Examples

ZPL validated with Labelixa

Working, tested Zebra ZPL label examples — shipping labels, product barcodes, QR codes, shelf labels, GS1-128/SSCC logistics and pallet labels, carrier-style parcel and marketplace product labels — plus copy-paste integration snippets for calling the Labelixa rendering API from curl, Python, Node.js and C#.

Every .zpl file in this repository is rendered and linted against the live ZPL engine in CI, so the examples cannot silently rot.

Quick start — see a label without a printer

Paste any example into the free ZPL viewer, or render it from the command line:

curl -X POST "https://api.labelixa.com/v1/printers/8dpmm/labels/4x6/0" \
     --data-binary @examples/shipping-label-4x6.zpl > label.png

No API key required for the free tier, and no plan watermarks the output; see the API reference for authentication, PDF output, ZPL→EPL2 translation and limits.

There is also a CLI in the official Node SDK:

npx labelixa preview examples/shipping-label-4x6.zpl --width 4 --height 6 --out label.png

Preview and lint from an AI assistant (MCP)

Labelixa runs a remote MCP server at https://api.labelixa.com/mcp, so an assistant can render and lint these files for you. We have tested it with Claude Desktop and Claude Code; other MCP-capable clients can point at the same endpoint, but we have not verified them ourselves.

Claude Code, one line:

claude mcp add --transport http labelixa https://api.labelixa.com/mcp

Claude Desktop (or any client that takes a JSON server entry):

{
  "mcpServers": {
    "labelixa": { "type": "http", "url": "https://api.labelixa.com/mcp" }
  }
}

Prefer a local process? The same tools ship as an npm package: npx -y labelixa-mcp (stdio transport, optional LABELIXA_API_KEY).

Then ask, for example:

Run zpl_validate on examples/shipping-label-4x6.zpl, then show me the render with zpl_preview at 8 dpmm, 4×6 in.

Tools used by these examples: zpl_validate, zpl_preview, zpl_command_help. The anonymous quota applies without an API key. Details and the current client list: labelixa.com/mcp.

Examples

File Size Shows Preview
examples/shipping-label-4x6.zpl 4×6 in Address blocks, Code 128 tracking barcode, separator lines (^GB), fonts (^CF) Preview
examples/product-label-ean13-2x1.zpl 2×1 in Retail EAN-13 barcode (^BE) with product name and price Preview
examples/qr-url-2x2.zpl 2×2 in QR code (^BQ) pointing to a URL Preview
examples/datamatrix-serial-1x1.zpl 1×1 in Compact Data Matrix (^BX) with human-readable serial Preview
examples/shelf-label-3x1.zpl 3×1 in Border box, mixed font sizes, price + SKU barcode Preview
examples/multi-label-batch-2x1.zpl 2×1 in ×3 Multiple ^XA…^XZ labels in one stream (render one page or all as PDF) Preview
examples/gs1-128-sscc-shipping-4x6.zpl 4×6 in GS1-128 logistics label: content (02)+(37) and SSCC (00) with ^BC mode D (FNC1, AIs in parentheses), human-readable lines Preview
examples/pallet-license-plate-4x3.zpl 4×3 in Pallet license plate: (01) GTIN + (15) best-before + (10) batch in one GS1-128, SSCC below Preview
examples/carrier-style-shipping-4x6.zpl 4×6 in Carrier-style parcel label: service frame (^GB), large routing text, PDF417 (^B7), Code 128 tracking Preview
examples/fba-fnsku-product-2x1.zpl 2×1 in FNSKU-style marketplace product label: Code 128 with interpretation line, title, condition Preview
examples/shopify-product-label-2x1.zpl 2×1 in E-commerce product label: title, variant, price, SKU as Code 128 Preview

Preview opens the file in the Labelixa viewer with size and resolution preset and renders it. The label travels in the URL fragment (#…), so nothing is uploaded or stored until the page renders it.

All examples target 8 dpmm (203 dpi) — the most common Zebra resolution. ^PW/^LL values are dots: inches × 203. The GS1-128 examples use ^BC…,D (mode D): the printer inserts FNC1 and the application identifiers are written in parentheses in ^FD — see GS1-128 vs Code 128 for why a plain Code 128 with the same digits is not GS1.

Integrations

File Stack
integrations/curl.sh curl — PNG, diagnostics, multi-label PDF
integrations/python-requests.py Python (requests) — or use the official SDK: pip install labelixa (PyPI)
integrations/node-fetch.mjs Node.js 18+ (built-in fetch, no deps) — or use the official SDK: npm install labelixa (npm)
integrations/csharp-httpclient.cs C# (HttpClient, .NET 6+)
integrations/java-httpclient.java Java 11+ (java.net.http, no deps)
integrations/go-nethttp.go Go (stdlib net/http, no deps)

All snippets do the same thing — POST raw ZPL, get a PNG back — so pick your language and adapt. Quota errors return 429 with a Retry-After header; respect it instead of hammering.

Batch: carrier ZPL labels to PDF, no Zebra needed

integrations/carrier-zpl-batch-to-pdf.py — Python 3 + requests. Carrier APIs (UPS, FedEx or your local carrier) return one ZPL label per parcel, often base64 inside JSON. This script takes a day's batch, renders it through the API and writes PDF files any printer can print.

pip install requests

# a folder of .zpl files -> labels.pdf, one 4x6 label per page at actual size
python carrier-zpl-batch-to-pdf.py ./labels/

# carrier JSON or JSONL; the field holds ZPL or base64 ZPL (auto-detected)
python carrier-zpl-batch-to-pdf.py shipments.jsonl --field zplBarcode

# one PDF per parcel, named after a field of the same JSON object
python carrier-zpl-batch-to-pdf.py shipments.jsonl --field zplBarcode \
    --split --name-field trackingNumber --out-dir ./pdf

# lint every label first, then four labels per A4 sheet
python carrier-zpl-batch-to-pdf.py ./labels/ --check --page a4 --layout 2x2

The default is one label per page, page = label size: what a thermal printer, or an office printer set to "actual size", expects. Sheets are opt-in with --page letter|legal|a4|a5|a6, --layout COLUMNSxROWS (default 1x1, 1 to 20 of each), --landscape and --no-border (no dashed cut line). --size (default 4x6, inches) and --dpmm (default 8 = 203 dpi; 12 for 300 dpi labels) must match what the carrier generated.

On a sheet the API never enlarges a label: each one is centred in its cell at true size and only shrinks when the cell is too small for it. Every sheet response carries X-Label-Scale (the share of true size, e.g. 0.90) and, below 85%, an X-Warnings line saying barcodes may not scan; the script prints both. Measured from real renders (8 dpmm):

Label --page --layout Labels per sheet Printed label X-Label-Scale
4×6 label (default) — 1 4×6 in — (page = label)
4×6 letter 1x1 1 4.0×6.0 in 1.00
4×6 letter --landscape 2x1 2 4.0×6.0 in 1.00
4×6 letter 2x2 4 3.4×5.1 in 0.84, warns
4×6 a4 1x1 1 4.0×6.0 in 1.00
4×6 a4 --landscape 2x1 2 4.0×6.0 in 1.00
4×6 a4 2x2 4 3.6×5.4 in 0.90
4×6 a4 2x3 6 2.4×3.6 in 0.60, warns
4×6 a5 1x1 1 4.0×6.0 in 1.00
4×6 a5 --landscape 2x1 2 3.6×5.4 in 0.89
4×6 a6 1x1 1 3.6×5.4 in 0.89
4×6 legal 1x2 2 4.0×6.0 in 1.00
4×6 legal 2x2 4 3.9×5.9 in 0.98
4×6 legal 2x3 6 2.9×4.3 in 0.72, warns
4×4 letter 2x2 4 3.9×3.9 in 0.98
4×4 letter 2x3 6 3.4×3.4 in 0.84, warns
4×4 a4 2x2 4 3.8×3.8 in 0.95
4×4 a4 2x3 6 3.6×3.6 in 0.90
4×4 a5 1x2 2 3.8×3.8 in 0.95
4×4 a5 --landscape 2x1 2 3.8×3.8 in 0.95
4×4 a6 1x1 1 3.8×3.8 in 0.95
4×4 legal 2x3 6 3.9×3.9 in 0.98

Six 4×6 labels on one A4 or Letter sheet print at about 60% or less and the carrier's barcodes may no longer scan; check with your carrier before you use it. For true size use the default label page, or a sheet with --layout 1x1 (A6 is the one sheet a 4×6 label does not fit at 100%).

The script checks --page and --layout before sending anything, against the same values the API accepts. If the API rejects a request anyway (HTTP 400), the script stops with the API's message, which lists the valid values; a rejected request renders nothing and is not counted against the quota.

Labels per request. The API renders at most this many labels in one request (HTTP 413 above it):

Plan Labels per request
No API key (anonymous), Free, Starter 50
Pro 100
Business, Enterprise 250

The script splits the batch into requests of 50 (--chunk-size to raise it on a larger plan; on a sheet it is rounded down to whole sheets) and keeps request bodies under the 1 MB limit. It writes one PDF per request — labels-001.pdf, labels-002.pdf, … (a single labels.pdf when the batch fits in one request) — instead of merging them, because merging PDFs would need a PDF library on top of requests. 200 labels are four files; print them in order, or merge them with any PDF tool you already have.

--check lints every label with /v1/diagnostics before rendering and prints each error with the file or JSON line it came from; rendering still runs and the exit code is 1 when errors were found. 429 and 503 answers are retried after their Retry-After; a used-up daily quota stops with a clear message instead. Set LABELIXA_API_KEY (LABELIXA_KEY also works) to send your key in the X-API-Key header and use your plan's quota; without it the free anonymous quota applies. Each rendered label counts once against the daily quota.

In a web framework

These four put the same call behind an HTTP route of your own, which is where it usually belongs: the API key stays on the server, and the label is linted before anything is printed.

File Stack
integrations/nextjs-route-handler.ts Next.js 13.4+ App Router route handler
integrations/express-server.mjs Express (Node 18+)
integrations/laravel-controller.php Laravel controller (Http facade)
integrations/dotnet-minimal-api.cs .NET 8 minimal API (IHttpClientFactory)

Automation: n8n workflow templates

Import any of these into n8n (Workflows → Import from file), pick a credential on the Labelixa node (Header Auth, name X-API-Key, value your lbx_... key — or leave it out for the free tier) and run.

Template What it does
integrations/n8n-webhook-to-png.json POST {"zpl": ...} to a webhook, get the rendered PNG back
integrations/n8n-sheets-to-barcode.json every new Google Sheets row becomes a barcode PNG; rows the API flags with X-Warnings are routed aside instead of printed
integrations/n8n-order-to-label.json order JSON from any shop or ERP → 4x6 shipping label (addresses, order number, Code 128 tracking)
integrations/n8n-bc-webhook-to-render.json Dynamics 365 Business Central item webhook (handshake + batch notifications) → fetch record → 2x1 product label

Each template carries a sticky note with the setup steps. The Code nodes strip ^ and ~ from user text (ZPL control characters) and cap line lengths, so a long street name cannot run off the label.

Automation: Make (Integromat)

integrations/make-http-module.md — three one-module recipes for Make's HTTP module: ZPL → PNG/PDF, lint before printing, barcode/QR as a file, plus the two settings that trip people up (raw body, unparsed response) and how to handle quota answers.

Two details these examples get right, and hand-written code often does not:

  • Lint with w and h, not width and height. The diagnostics endpoint ignores unknown query parameters silently, so the wrong spelling checks every label against the 4x6 default and reports a clean bill of health for a label that does not fit.
  • Pass X-Warnings on. It is the one signal that says the renderer had to skip something — an unknown command, a field off the label.

Open it without installing anything

  • In the browser: open this repository in StackBlitz.
  • In a container: the repository carries a .devcontainer, so GitHub Codespaces and VS Code Dev Containers start with Node, the CLI and the ZPL extension already there.

ZPL cheat notes

  • A label is ^XA … ^XZ. Fields start with ^FO x,y (position in dots) and end with ^FS.
  • ^FD carries the data of the preceding field/barcode command.
  • ^BY sets barcode module width; ^BCN,180,Y,N,N = Code 128, height 180 dots, print interpretation line.
  • Full per-command reference with parameters and rendered examples: labelixa.com/zpl-commands.

License

MIT — use these labels freely in your own projects.

About

Working, tested Zebra ZPL label examples — shipping labels, barcodes, QR — with curl/Python/Node/C# integration snippets.

Topics

zplzpl-printerzpl2pdf

Resources

Readme
MIT license

Security policy

Security policy
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.