Barcodes with ZPL
Complete guide to 10 barcode types for Zebra printers with practical examples and configuration
Try our free ZPL tools right now
Free, no signup required — Instant results
Barcodes in ZPL
ZPL supports over 30 barcode types between 1D (linear) and 2D (two-dimensional). Each type has its own command and specific parameters. The ^BY command is essential: place it BEFORE the barcode command to define module width (bar thickness), the wide-to-narrow ratio, and default height. This guide covers the 10 most widely used types in logistics, retail, manufacturing and pharmaceuticals — with copy-ready examples optimized for shipping platforms like Amazon, eBay, Shopify, FedEx and UPS, and compatible with printers from Brother, DYMO, Rollo and Zebra.
Barcode types
Code 128
^BCThe most widely used barcode in global logistics and shipping. Encodes all 128 ASCII characters (numbers, upper and lowercase letters, symbols). Has 3 automatic subtypes: A (uppercase + control), B (upper + lowercase) and C (numeric only, more compact). The printer selects the optimal subtype automatically.
Ejemplo de código:
^XA ^FO50,50^BY2 ^BCN,100,Y,N,N ^FD123ABC456^FS ^XZ
Casos de uso:
- Shipping labels (Amazon, eBay, FedEx, UPS)
- Serial numbers and lot tracking
- Warehouse product identification
- Parcel logistics and transportation
QR Code
^BQ2D code that stores up to 4,296 alphanumeric characters or 7,089 digits. Supports error correction (levels L, M, Q, H) allowing the code to be read even if partially damaged. The data prefix defines the mode: QA (automatic), QM (manual). Requires prefix FDQA, or FDMM,A for data with special characters.
Ejemplo de código:
^XA ^FO50,50 ^BQN,2,5 ^FDQA,https://zplpdf.com^FS ^XZ
Casos de uso:
- URLs and web links on labels
- Extended product information
- Tickets, boarding passes and event entry
- Marketing and campaign tracking
EAN-13
^BEGlobal standard for consumer products in retail. Used throughout Europe, Asia, Latin America and international markets. Requires exactly 12 data digits (the 13th check digit is calculated automatically). The first digits identify the country of origin (000-019 = USA/Canada, 400-440 = Germany, 500-509 = UK).
Ejemplo de código:
^XA ^FO50,50^BY2 ^BEN,100,Y,N ^FD012345678901^FS ^XZ
Casos de uso:
- Supermarket and retail products
- Inventory with point-of-sale (POS) systems
- Price tags in brick-and-mortar stores
- International product cataloging
UPC-A
^BUThe primary standard for consumer products in the United States and Canada. Required by major retailers like Amazon, Walmart, Target and Costco. Requires exactly 11 data digits (the 12th check digit is calculated automatically). The North American equivalent of EAN-13 — scanners at US retailers are tuned for this format.
Ejemplo de código:
^XA ^FO50,50^BY2 ^BUN,100,Y,N ^FD12345678901^FS ^XZ
Casos de uso:
- Retail products sold in the US and Canada
- Amazon, eBay and Shopify listings
- US point-of-sale and inventory systems
- Shelf labels and price tags
Code 39
^B3One of the oldest and most widely adopted barcodes in industry. Encodes only uppercase letters (A-Z), numbers (0-9) and 7 special symbols (-, ., space, $, /, +, %). Self-checking (no mandatory checksum required). Lower density than Code 128 but compatible with virtually every scanner on the market.
Ejemplo de código:
^XA ^FO50,50^BY2 ^B3N,N,100,Y,N ^FDABC-123^FS ^XZ
Casos de uso:
- Automotive industry (AIAG standard)
- Defense and government (MIL-STD-1189)
- Healthcare and laboratory specimens
- Industrial inventory control
DataMatrix
^BXExtremely compact 2D code capable of storing up to 2,335 alphanumeric characters in a very small area. Has built-in Reed-Solomon error correction (tolerates up to 30% damage). The quality parameter (0-200) controls the level of redundancy. Ideal for direct part marking (DPM) on metal, plastic and glass surfaces.
Ejemplo de código:
^XA ^FO50,50 ^BXN,5,200 ^FDSN:ABC123456^FS ^XZ
Casos de uso:
- Electronic components and PCBs
- Pharmaceuticals (GS1 standard)
- Direct part marking on metal surfaces
- Medical devices and traceability
PDF417
^B7High-capacity stacked 2D code that stores up to 1,850 alphanumeric characters or 2,710 digits. Supports 9 security levels (error correction). Can encode text, numbers and binary data. The legal standard for identity documents in many countries and widely used by airlines.
Ejemplo de código:
^XA ^FO50,50 ^B7N,5,2,3,10,N ^FDExtensive data here^FS ^XZ
Casos de uso:
- Driver's licenses and ID cards
- Airline boarding passes
- Government identity documents
- Forms with large amounts of structured data
Aztec
^BOCompact 2D code that does NOT require a quiet zone (white border) around it, making it ideal for very tight spaces. Stores up to 3,832 digits or 3,067 characters. Supports configurable error correction. Magnification controls the symbol size. Commonly used in transit ticketing systems worldwide.
Ejemplo de código:
^XA ^FO50,50 ^BON,5,N ^FDCompact Aztec data^FS ^XZ
Casos de uso:
- Public transit and rail tickets
- Labels in very confined spaces
- Applications where no quiet zone is available
- Electronic travel documents
GS1-128 (EAN-128)
^BC with FNC1A variant of Code 128 that uses GS1 Application Identifiers (AI) to encode structured information such as expiration dates, lot numbers, weight and serial numbers. Activated by using the FNC1 character (>8) at the start of the data field. Mandatory in supply chains that follow the GS1 standard — required by major retailers like Walmart, Target and Amazon vendor programs.
Ejemplo de código:
^XA ^FO50,50^BY2 ^BCN,100,Y,N,N ^FD>801034531200000111719112510ABC123^FS ^XZ
Casos de uso:
- GS1-compliant supply chains (Walmart, Target)
- Food product traceability
- Pharmaceuticals (date + lot + serial)
- Logistics with structured information
Interleaved 2 of 5
^B21D barcode that encodes only numeric digits in pairs (always an even number of digits). Very compact for pure numeric data. Each pair of digits is encoded by interleaving bars and spaces, reducing the space required. If you have an odd number of digits, prepend a leading zero. Widely used for carton-level shipping labels (ITF-14).
Ejemplo de código:
^XA ^FO50,50^BY2 ^B2N,100,Y,N ^FD1234567890^FS ^XZ
Casos de uso:
- Distribution and warehouse operations
- Carton and pallet labels (ITF-14 standard)
- Financial and banking sector
- Shipping container identification codes
Barcode tips for ZPL
- Always place ^BY BEFORE the barcode command to define module width, ratio and height
- Use ^BY2 as the standard setting — ^BY1 may be difficult to scan, ^BY3 takes more space
- Leave sufficient quiet zone: minimum 10 times the module width on each side of a 1D barcode
- For QR codes, use magnification 5 as a starting point and adjust based on label size
- Always enable the human-readable interpretation line (Y parameter) so the number is visible below the bars
- Verify every barcode with a real scanner before production — the viewer helps but the scanner is the definitive test
- For shipping and logistics (FedEx, UPS, USPS), Code 128 (^BC) is the universal standard — avoid Code 39 unless required
- 2D codes (QR, DataMatrix) are ideal when you need to store more than 20 characters of data
- On small labels, prefer DataMatrix or Aztec over QR — they are more compact for the same amount of data
- If the barcode does not scan, first check ^BY (module width), then print darkness (~SD) and print speed (^PR)
Frequently asked questions about ZPL barcodes
Which barcode should I use for shipping labels?
What is the difference between Code 128 and GS1-128?
How do I control the size of a barcode in ZPL?
Why is my barcode not scanning correctly?
When should I use a 2D code instead of a 1D code?
Do ZPL barcodes work on non-Zebra printers like Brother, DYMO or Rollo?
How do I add a QR code with a URL in ZPL?
Test your barcodes
Visualize and verify your ZPL barcodes with our free tools before printing.