ThermalPrint Manual GitHub
On this page

Barcode reference

ThermalPrint draws real barcodes, not pictures of them. Pick the type your scanner, shop, or carrier expects. If you are not sure, Code 128 is the safest general-purpose choice.

A sheet showing a sample of each barcode type: Code 128, Code 39, Code 93, EAN-13, EAN-8, UPC-A, ITF, Codabar, and Data Matrix
One sample of each type, drawn by ThermalPrint at 300 DPI.

Choosing a type#

TypeAcceptsTypical use
Code 128Letters, digits, and punctuation: any printable ASCII character (space to ~).Product references, SKUs, shipping, inventory. Compact and flexible.
Code 39Capital letters A–Z, digits 0–9, and - . space $ / + %.Industrial and government labels, asset tags. Easy to read but wide.
Code 93The same characters as Code 39.A denser alternative to Code 39.
EAN-1312 digits (the check digit is added for you), or 13 digits with a correct check digit.Retail products outside North America.
EAN-87 digits, or 8 digits with a correct check digit.Retail products too small for EAN-13.
UPC-A11 or 12 digits.Retail products in North America.
ITF (Interleaved 2 of 5)Digits only, in an even number.Shipping cartons and warehouse boxes.
CodabarStarts and ends with A, B, C, or D; digits and - $ : / . + in between.Libraries, blood banks, some parcel systems.
Data MatrixAny text.Very small parts and labels; a square 2D symbol.
GS1-128GS1 data written with the identifier in brackets, such as (01)09506000134352(10)LOT7.Pallet, carton, and parcel labels in logistics and retail supply chains.
GS1 Data MatrixThe same GS1 data, with any batch or serial field last.Small labels that carry a product number and a batch or serial.
QR codeAny text, up to 2,048 characters.Web addresses, contact details, longer data.

Some types check themselves. If you give an EAN-13 or EAN-8 its check digit and it is wrong, ThermalPrint refuses it instead of printing a barcode that would not scan. Give 12 (or 7) digits and the correct check digit is added.

GS1 barcodes#

GS1 labels carry elements: an application identifier (AI) in brackets followed by its value. ThermalPrint checks each one before it prints, so a typo is reported instead of becoming a barcode that does not scan.

A GS1-128 barcode selected in the Label Designer with the data (01)0950600013435(10)LOT7 and the text it prints as
A GS1-128 barcode. A line under the settings shows exactly what will print, with the check digit added.
AIMeaningValue
(00)SSCC, a pallet or parcel number18 digits, or 17 and the check digit is added
(01), (02)Product number (GTIN)14 digits, or 13 and the check digit is added
(10), (21)Batch or lot, serial numberUp to 20 letters, digits, or symbols; no spaces
(11), (13), (15), (17)Production, packaging, best-before, and expiry dates6 digits as YYMMDD
(20), (30), (37)Variant, count, number of unitsDigits
(310n) to (316n), (320n) to (325n)Weights, lengths, and other measures with n decimals6 digits
(240), (241), (242), (400), (401), (410) to (415), (420)Additional product and order numbers, locations (GLN), and postal codeAs the standard defines

Other identifiers are refused. In a GS1-128 barcode, a variable-length field that is followed by another one is separated for you with the FNC1 control character. In a GS1 Data Matrix this separator is not available, so put the one variable-length field (batch or serial) last; ThermalPrint tells you if you do not.

The SSCC helper under the barcode settings builds a pallet or parcel number: enter the extension digit (0 to 9), your GS1 company prefix (6 to 12 digits), and a serial reference. It pads the serial with zeros, adds the check digit, and fills the barcode with (00) and the number.

Error messages and what they mean#

MessageFix
Barcode data is emptyType a value.
Code 128 currently accepts printable ASCIIRemove accented or special letters, or use a QR code or Data Matrix, which accept any text.
EAN-8 requires 7 digits, or 8 including the check digitUse digits only, with the right count.
UPC-A requires 11 or 12 digitsUse digits only, with the right count.
ITF requires an even number of digitsAdd a leading zero if you need an even count.
Codabar must start and end with A, B, C, or D …Frame the value, for example A12345B.
Barcode is too narrow at N DPI. Widen it or use a shorter value.Make the object wider or the value shorter. Each bar needs at least two printed dots.
Data Matrix is too small; enlarge the object or use shorter dataMake the box bigger. Keep it roughly square.
QR code is too small; enlarge the objectMake the box bigger.
QR code is too small for a logo; enlarge the object or remove the logoA code with a logo needs squares of at least three printed dots. Make the QR object bigger, or take the logo off. See A logo in the middle.
The QR logo could not be readThe picture stored in the design is damaged. Press Change logo… and choose it again.
(01) has a wrong check digitFix the last digit, or leave it off and it is added.
In a GS1 Data Matrix, put the variable-length field … lastReorder the elements, or use GS1-128.
Barcode data is too longThe limit is 2,048 characters.

Making barcodes scan#

  • Leave quiet space. Keep a blank margin of at least a few millimeters on each side of a barcode. Text or lines touching the bars can stop a scanner reading it.
  • Print large enough. Thin bars are the usual cause of failed scans. Prefer wider objects, and print at your printer's real DPI (203 DPI is common).
  • Keep it black and white. Avoid gray fills behind or inside a barcode.
  • Test a real label. Scan the first label with your phone or a scanner. ThermalPrint does not read a barcode back to test it, and it cannot read barcodes in imported labels.
  • A logo in a QR code needs a bigger code. Keep the logo at or below the limit shown next to the size slider, and make the code at least the width the red note asks for. Test one printed label with your phone first.
  • Data Matrix and QR need to be square-ish. A symbol is drawn as a square in the middle of its box; a very wide box wastes space.

You can use ${date}, ${serial}, and (in a batch) ${Column} placeholders inside any barcode value. See Dynamic text and Batch printing.