ZPL II · barcodes · 152–600 dpi · CSV merge

ZPL Label Viewer

Paste or open ZPL and see each label at its printer resolution. The ZPL is parsed and drawn in this browser tab, so it is never sent to a rendering service.

ZPL

1 label, 63 commands

Open a .zpl, .txt or .prn file

Up to 8 MB of text

Label and printer

A label with no ^PW takes the width and height above. Dot positions in ZPL are absolute, so changing the dpi changes the physical size, as on a printer.

Preview

Add ZPL to see the label.

Zebra's resident fonts are proprietary, so ^A0 uses your system sans-serif and fonts A to H use a monospace face in Zebra's character cell sizes. Expect text widths to differ by a few percent from a printer.

Merge a CSV into ^FN fields

The first label of the ZPL above is the template

Open a CSV with one row per label

Column 1 fills ^FN1, column 2 fills ^FN2, or name the field as ^FN1"Header"

Label designer

Builds ZPL you can paste into a printer or open above

ZPL Label Viewer

Operator: Abdulla Al Fahad. How tools are built and checked

A shipping label that looks fine in a text editor can print with a barcode cut off, a name pushed over the edge or a field in the wrong place, and the only way to know is to send it to a printer or paste it into a rendering service. This viewer draws the ZPL in the page, at the printer's own resolution, so you can see the label before it prints. Labels often hold names, addresses and order numbers, so nothing is posted to a third-party renderer, unlike Labelary's online viewer.

It reads many labels from one file, shows each ^PQ copy when ^SN changes the serial number, merges a CSV into ^FN fields to make batch print files, and has a small designer that writes ZPL.

What it draws is a faithful picture of the commands it understands and says which ones it skipped, because a viewer that hides an unsupported command gives false comfort.

Key features

  • 152, 203, 300 and 600 dpi with the label size from ^PW and ^LL or from your own width and height
  • Text with ^A0 and fonts A to H, ^CF, ^FB blocks with wrapping, justification and line spacing, ^FR reverse fields, ^FH hex escapes and ^FT baseline positioning
  • Graphics: ^GB boxes with rounded corners, ^GC circles, ^GE ellipses, ^GD diagonals and ^GFA bitmaps in hex with ZPL run-length compression or :Z64: and :B64: data
  • Linear barcodes ^BC Code 128, ^B3 Code 39, ^BE EAN-13, ^B8 EAN-8 and ^BU UPC-A with interpretation lines above or below
  • 2D barcodes ^BQ QR code, ^BX Data Matrix, ^B7 PDF417 and ^BO Aztec
  • ^FN field numbers with CSV merge and ^SN serialisation across ^PQ copies, ^LH, ^LT and ^PO I
  • PNG per label, and every label as one PDF at its physical size or a ZIP of PNGs
  • A designer for text, Code 128, QR and box elements that writes ZPL with ^FH escapes

What the viewer draws, and what it ignores

ZPL positions everything in dots from the label's top-left corner, so the same code is a different size at each resolution: 152 dpi is 6 dots per millimetre, 203 dpi is 8, 300 dpi is 12 and 600 dpi is 24. A 4 by 6 inch label at 203 dpi is 812 by 1218 dots. Changing the dpi on this page therefore changes the physical size, as it would on a printer.

Commands start with ^ or ~ and take comma-separated parameters. Field data after ^FD runs to the next ^, so a ~ inside it is data. With ^FH, an underscore (or the character you give) followed by two hex digits is one byte, which is how a caret or tilde reaches the label; the page decodes those bytes as UTF-8.

^BQ data starts with an error-correction letter and a mode letter, such as QA, in front of the text. ^BC accepts the invocation codes >9, >: and >; and ignores them, choosing the code sets itself. ^GF is read in format A only; the binary formats B and C need the raw printer stream.

Commands that configure the printer, such as ^MM, ^MN, ~JC and RFID commands, are read and listed as having no effect on the picture. Commands the viewer does not draw, such as Interleaved 2 of 5, MaxiCode or ^XG recall, are named in a note, and a small warning mark is drawn where the barcode would be instead of printing its digits as text.

How it works

The text is cut into labels at ^XA and ^XZ and each command is interpreted in order into a list of shapes: rectangles, rings, polygons, bars, text lines and bitmaps. The list is then painted on a canvas at the label's size in dots, so the same list serves the preview, the PNG and the PDF.

Linear barcodes come from the Code 128, Code 39, EAN and UPC encoders already on this site, QR codes from the qrcode library, and Data Matrix, PDF417 and Aztec from the zxing-wasm writer, whose WebAssembly file is served from this site and loads when a 2D code first appears.

Reverse fields are painted with a difference blend, so black on white becomes white on black exactly where the field overlaps ink, and ^GFA data is expanded in a bounded buffer so a hostile file cannot grow without limit.

When this helps

  • A warehouse team gets a vendor's ZPL for a pallet label and sees that the 600 dpi file prints half-size on their 300 dpi printers. Switching the preview between 300 and 600 dpi shows the same dots at two physical sizes.
  • A developer builds ZPL strings in code and escapes ^ and ~ by hand. The designer shows what correct ^FH escaping looks like: a text of Hi ^FS~ becomes Hi \5EFS\7E with ^FH\.
  • A marketplace seller prints 500 labels from an order export. The CSV merge turns one template with ^FN1 and ^FN2 into 500 labels and the viewer pages through them before they are sent to the printer.
  • A label with ^SN001,1,Y and ^PQ3 shows copies 001, 002 and 003 as separate previews, which is how a printer would number them.

Opening a file

  1. Paste ZPL, open a .zpl, .txt or .prn file, or press Load example.
  2. Pick the resolution and, if the ZPL has no ^PW and ^LL, the label size.
  3. Step through the labels, read the notes under the preview, and download a PNG or all labels.
  4. To make a batch, put ^FN1, ^FN2 and so on before each variable ^FD, open a CSV and download the merged .zpl.

Example

The Load example label: 4 x 6 inch at 203 dpi, ^PW812 and ^LL1218, with a ^BY4 Code 128 of 420558029400111206, a ^BQ code at magnification 6 and a reversed P2 on a ^GB block

63 commands counting ^XA and ^XZ

What the preview reports

812 x 1218 dots, 15 drawn elements, no notes
Code 128: 134 modules (start, nine digit pairs in code set C, check symbol 6, stop) = 536 dots wide at 4 dots per module
QR code: 33 modules = 165 dots square at magnification 5

Tips for best results

  • Check the note list after each change. Every command that was skipped is named there, so a missing element can be traced to a command instead of a guess.
  • For a barcode that must scan, compare the module width: at 203 dpi, ^BY2 makes bars 0.25 mm wide, and ^BY1 at 152 dpi is about 0.17 mm.
  • Use ^FT, not ^FO, for text that must sit on a baseline, such as a line under a barcode, and look at the preview of rotated fields, because ^FO measures a rotated field from its top-left corner.
  • Raise the preview to 600 dpi before judging fine bitmaps or small QR modules.
  • Put ^CI28 at the start of a label that carries UTF-8 text through ^FH escapes, as the CSV merge does. The viewer decodes those bytes as UTF-8 either way, and the printer needs ^CI28 to do the same.

Limits

Zebra's resident fonts are proprietary. ^A0 is drawn in your system's bold sans-serif and fonts A to H in a monospace face using Zebra's character cell sizes, so text widths and line breaks can differ from a printer by a few percent. Leave margin around text that is close to its limit.

Printer settings that are not in the ZPL, such as darkness, speed and the media sensors, are not simulated, and neither is how dark a barcode prints.

Settings from earlier labels, such as ^CF and ^BY, are not carried to the next label: each ^XA starts from the defaults, as it would after a printer reset.

Common errors and how to fix them

No label found. A label starts with ^XA and ends with ^XZ
The text has no ^XA...^XZ pair, or it was pasted with the carets stripped. Check the source and the ^ characters.
Barcode skipped: a character is not valid in Code 128 (or another symbology)
EAN and UPC data must be digits of the right length, and Code 39 allows only its set of capitals and symbols. Fix the data; the missing barcode is also marked on the label.
^GF only reads format A
Binary and compressed-binary graphics cannot be carried in pasted text. Export the graphic as ASCII hex or :Z64: data.

Frequently asked questions

Does it match Labelary pixel for pixel?

Not exactly, and it has not been compared against Labelary's output. Positions, boxes, barcodes and bitmaps are placed from the same dot coordinates; text is where the two differ, because Zebra's fonts are not available.

Why does a barcode have no text below it?

The interpretation line is the second parameter after the height in ^BC, ^BE, ^B8 and ^BU, and the third in ^B3. N turns it off, and the default is Y.

How do I print the same label with different data?

Put ^FN1, ^FN2 and so on before each variable ^FD, then merge a CSV. Column 1 fills ^FN1, column 2 fills ^FN2, or name a field as ^FN1"City" to take the column headed City.

Do the barcodes decode?

In the checks, Code 128, Code 39, EAN-13, EAN-8, UPC-A, QR, Data Matrix, PDF417 and Aztec symbols drawn by the renderer were each read back to the original data by a barcode reader. UPC-A is reported by the reader as an EAN-13 with a leading zero.