Guard pattern
A fixed bar pattern that bookends or divides a barcode symbol. Scanners use it to lock onto the symbol and self-calibrate.
What is a guard pattern?
A guard pattern is a short, predetermined sequence of dark and light modules that appears in every barcode of a given symbology - never varying with the data being encoded. The pattern's job is to tell the scanner this is the start (or end, or middle) of the symbol, and to give the scanner a known-width sample to calibrate its sense of the X-dimension against.
Guard patterns are distinct from start and stop characters - the difference is covered in detail below.
EAN / UPC guard patterns
Every EAN-13 , EAN-8 , UPC-A , and UPC-E symbol has three guard patterns:
101 (3 modules)Marks the start of the symbol on the left.
01010 (5 modules)Separates the left- and right-half digit groups in the middle of the symbol.
101 (3 modules)Marks the end of the symbol on the right.
Notice that the left and right guards are identical (101). The centre guard is also symmetric. This palindromic property is deliberate - it's how scanners detect whether they are reading the symbol forwards or in reverse, and why every EAN-13 can be scanned upside-down without confusing the decoder.
What guard patterns do for the scanner
- Symbol detection. Inside the quiet zone , the scanner's algorithm hunts for the specific bar/space pattern
101. Find it, and the scanner knows a symbol starts here. - X-dimension calibration. The scanner doesn't know the printed X-dimension in advance - the same EAN-13 might be printed at 80% or 200% size. The known-width guard gives it a reference: "if the left guard's three modules occupy 12 sample-clocks, then one module is 4 sample-clocks wide".
- Orientation detection. The relationship between left guard, data, centre guard, data, right guard is asymmetric in the digit positions even though the guards themselves are symmetric. That lets a decoder know which end is left.
- Half-symbol scan. A retail scanner that catches only the right half of a flying box can still decode by detecting the centre guard + right guard + the six right-half digits.
Guard pattern vs start/stop character
- A fixed bit pattern - not a character from the symbology's alphabet
- Used by EAN/UPC family, GS1 DataBar, and a few others
- Always the same regardless of data
- Not visible in the human-readable text
- A character chosen from the symbology's alphabet
- Used by Code 39, Codabar, Code 128
- May vary (Codabar's A/B/C/D, Code 128's three start codes)
- Often visible (Code 39's
*) or implicit (Code 128's silent start)
Other symbologies that use guards
- GS1 DataBar - uses a "finder pattern" that plays the same role as a guard. The DataBar finder is more complex (it carries linkage information for stacked variants) but functionally it's a fixed pattern bookending the data.
- Codabar - uses A/B/C/D characters as start/stop. These are characters in the alphabet and carry semantic meaning (chosen by the encoder), so they sit between the guard and start-stop concepts.
- 2D matrix codes (QR, Data Matrix, Aztec) - use finder patterns (QR's three corner squares, Aztec's central bullseye, Data Matrix's L-shaped solid border) which are the 2D equivalent of a guard pattern. They are fixed bit patterns that tell the scanner where the symbol is and how it is oriented.