What a barcode is and how it is read

· Code types · 4 min read

What a barcode is and how it is read

What is a barcode: the bars hold only a sequence of digits, while the name and price of an item live in your database. Here is how a scanner reads the bars.

At the till, the cashier passes an item over the scanner and the name and price appear on screen. Many people conclude from this that the code holds everything about the product. It does not, and anyone who understands the difference saves a storekeeper and an accountant from a lot of mistakes.

What a code really contains

An ordinary linear barcode stores one thing: a sequence of digits (and, in some types, letters). The product name, price, manufacturer or expiry date are not in the bars. They live elsewhere: in the 1C item catalogue, in an Excel sheet or in the database of the till software. The code is simply the key that finds the right record.

Say the scanner reads 4780000123454. The software looks that number up and opens the item card: "Flour, premium grade, 25 kg", the price, the stock on hand. If the number is not in the database, the software reports "item not found". The scanner is not to blame, because it read the number correctly.

That is why the same product must always be kept under the same code. If one product is stored under two different numbers, the scanner will read both, but the software treats them as two separate items and the stock is split in half.

How a scanner reads the bars

Black bars absorb light and white spaces reflect it. The scanner emits a beam (a laser or an LED), catches the reflection with a sensor and turns it into electrical signals. A decoder then measures the width of the bars and gaps: a thin bar is one unit, a thick one is two or three. Each digit is defined by one exact pattern of widths.

The process runs roughly like this:

  1. The scanner finds the blank margin on either side of the code (the quiet zone) and works out where to start reading.
  2. The widths of the bars are measured and converted into digits.
  3. The check digit is verified: if the arithmetic does not agree, the scanner discards the read and gives no beep.
  4. The number is sent to the computer or phone as if typed on a keyboard, usually followed by Enter.

The last step is very handy in practice: most scanners appear to the software as an ordinary keyboard. You can therefore plug one into any input field in 1C or Excel without a separate integration.

The main code types

Linear (1D) codes are a single row and are read only horizontally. Two-dimensional (2D) codes, such as QR and Data Matrix, store data both across and down, so they hold far more. In a warehouse you will meet these most often:

  • EAN-13 for retail product packaging, 13 digits.
  • Code 128 for internal labels, pallets and racks; it packs letters and digits compactly.
  • QR code when you need a link or more data; a phone camera reads it too.

The scanner type matters too: a laser scanner reads only linear codes, while an imager reads both linear and two-dimensional ones. If you may adopt QR or Data Matrix later, choose the scanner with that in mind now.

Each type has its own strengths and limits, and they deserve separate articles. The point here is different: whichever type you pick, the logic is the same.

The scanner reads the number; your database supplies the meaning.

What to watch in a warehouse

Before printing new labels, check three things:

  • the code is tied to exactly one product in the database (if the pack, size or colour differs, the number must differ too);
  • the printed label scans on the first try with an ordinary scanner;
  • the number does not lose its leading zeros when it lands in Excel: set the column to text format, otherwise a code like 0012345... becomes 12345...

The third mistake is especially common. Excel displays a long number as 4.78E+12, drops leading zeros and, for codes longer than 15 digits (pallet numbers, for example), replaces the tail with zeros. Switching the column to text before you paste the codes is enough to avoid it.

Conclusion

A barcode is just a way to read a number quickly and without errors; all the rest of the meaning lives in your own database. When the code system is tidy, counts go fast and shortages show up while they are still small. The Shtrix team counts goods and fixed assets by barcode, prepares labels and hands over the results in a file ready for 1C or Excel.