What is a bar? What is a space?

A bar is a dark element - a single dark module or a run of adjacent dark modules treated as one element. A space is the corresponding light element: a single light module or a run of adjacent light modules. Every 1D linear barcode is just an alternating sequence of bars and spaces, read left to right.

A scanner doesn't "see" individual modules. It sweeps a beam across the symbol, samples the analog reflectance signal, and converts each light-to-dark and dark-to-light transition into the next element. The decoder then measures the widths of those elements - in modules, or relative to each other - and looks the resulting pattern up in the symbology's character table.

Bar/space vs. module

The distinction is subtle but it shows up on every other page in this glossary:

  • Module is the unit - the smallest dark or light cell. It has a fixed physical width (the X-dimension ) for any given symbol.
  • A bar or space is a run - one or more adjacent modules of the same colour, treated by the decoder as a single element with a measurable width.

A bar that is "3 modules wide" is one bar, not three. The number of bars and spaces in a symbol is much smaller than the number of modules: an EAN-13 character is 7 modules but only 4 elements (2 bars + 2 spaces), and a Code 128 character is 11 modules but only 6 elements (3 bars + 3 spaces).

How widths are counted: module-based vs. width-based

1D symbologies fall into two families based on how they specify bar and space widths:

Module-based

Every bar and space is an integer number of modules (typically 1-4). The decoder measures each element's width and rounds to the nearest module count.

  • Code 128 - 11 modules per character, element widths 1-4
  • EAN/UPC - 7 modules per digit, element widths 1-4
  • GS1 DataBar - finder + data with module-count patterns
  • Code 93 - 9 modules per character, element widths 1-4
Width-based (two-width)

Every bar and space is either narrow ("N") or wide ("W"). There are only two element widths in the entire symbol, and the wide-to-narrow ratio is fixed by the spec (typically 2:1 to 3:1).

  • Code 39 - 9 elements per character, 3 of which are wide
  • Codabar - 7 elements per character, 2-3 wide
  • Interleaved 2 of 5 / ITF-14 - 5 elements per digit, 2 wide
  • Industrial 2 of 5, MSI Plessey

Module-based symbologies pack more data into the same physical width - four distinct element widths give more codepoints per element. Width-based symbologies are easier to print and scan because the decoder only has to distinguish two widths, which is why they survive on thermal-transfer printers, hand-stamped labels, and direct-part-marking.

Module-based vs. width-based - side by side

The two SVGs below show one character from each family at the same scale (one module = one narrow element). The numbers under each element are its width: modules for Code 128, N or W for Code 39.

Code 128 - character "A"module-based: 6 elements, 11 modules total
1b1s1b3space2bar3space
Code 39 - character "A"width-based: 9 elements, 3 wide + 6 narrow
WbarNsNbWspaceNbNsNbNsWbar

Both characters carry roughly the same amount of information, but the Code 39 symbol is wider because it needs nine elements (with 3 of them three modules wide) instead of six elements with mixed module counts. (Narrow elements are labelled b/s to fit; wider elements spell bar/space in full.)

Reading direction

A 1D linear barcode is read left to right - the convention every symbology start pattern is designed around. Most scanners can detect that the symbol is upside-down by recognising the start pattern at the right end of the scan instead of the left, and they silently reverse the decoded string. Symbologies like Code 128 and EAN/UPC have deliberately asymmetric start/stop patterns to make this orientation detection unambiguous.

The decoder works on element widths, not absolute positions, so the symbol scales with X-dimension : a barcode printed at 13 mil reads the same as the same barcode printed at 6.6 mil, just faster (the scanner sweeps the small one in less time).

Related