How do barcodes work?
A UPC is a 12 digit number drawn as 30 bars. Each digit takes seven narrow columns, and every bar and space is one to four columns wide. A scanner shines red light across those columns, measures what bounces back and works out the digits from the widths. It checks the last digit, then types the number into the till as if someone had keyed it.
By the UPC Generator team. The module counts, sizes and grades come from the GS1 General Specifications, Release 26.0, and GS1 US placement advice. Scanner makers' own explainers and Wikipedia's articles on barcodes and readers fill in how a reader works. The module counts and widths are the ones the UPC generator draws. Last updated 4 November 2026. How UPC Generator pages are made.
From a number to bars
Every digit in a UPC or EAN takes seven columns of equal width, called modules, and is drawn as two bars and two spaces. Each bar or space is one, two, three or four modules wide, and the four widths always add up to seven. GS1 defines three sets of patterns for the digits, called A, B and C. A zero in set A, for example, is a space three wide, a bar two wide, a space one wide and a bar one wide.
Three guard patterns frame the digits. A guard of bar, space, bar sits at each end and a five column guard in the middle. They tell the scanner where the symbol starts, where it ends and how wide a module is. Add them up and a UPC-A is 95 modules across, which IBM's history page describes as 30 black lines and 29 blank ones. The UPC generator draws your number and lights up the columns for any digit you pick. What the digits mean is in what a UPC code is.
Reading either way up
The six digits on the left of a UPC-A come from set A, where each pattern has an odd number of dark modules. The six on the right come from set C, which is the mirror image of set B, and have an even number. A scanner that passes a guard and then meets odd patterns knows it is reading left to right. Even patterns mean it is reading backwards and should reverse the result. That is why a cashier can swipe a product in either direction, and why GS1 calls the EAN and UPC family omnidirectional.
What the scanner sees
A scanner sees changes in reflected light along a line rather than a picture of bars. A pen reader is dragged across the bars and a photodiode turns the bright spaces and dark bars into a waveform. A laser scanner sweeps its beam with a spinning mirror, between 200 and 1,200 times a second, and a photodetector reads the reflection. A CCD reader has a row of hundreds of light sensors and measures the light already falling on the code. A camera scanner, which GS1 calls an imager, takes a picture and finds the bars in it.
The difference matters for what each can read. Zebra says a laser scanner reads printed linear codes well, even poor ones. Zebra adds that it cannot read a code on a phone screen and cannot read a 2D code. A camera imager reads printed and on-screen codes, both linear and 2D, from any angle. GS1 assumes a retail scanner reads from about 100 mm away. Wikipedia gives 0.33 mm as the most common narrow bar width, with some scanners reading bars as thin as 0.075 mm.
Whatever the hardware, the decoder measures the distance from the edge of one bar to the edge of the next similar one. It compares those distances with the width of a whole digit and picks the digit whose pattern fits. GS1 publishes that reference method so that any maker's scanner reads any maker's symbol.
Why red bars disappear
Scanning lasers shine red light, and GS1 grades barcode print quality with light at 660 nanometers for the same reason. Under red light, red ink reflects almost as much as white paper, so GS1 US says red or reddish bars are invisible to a laser. A reddish background is acceptable for the opposite reason. Black bars on a white background remain the safe choice, printed in a single ink.
Clear space, height and size
The scanner needs empty space on both sides to find the first and last bars. GS1 asks for 9 modules of clear space on each side of a UPC-A. That is 2.97 mm at the standard module width of 0.330 mm. An EAN-13 needs 11 on the left and 7 on the right. The whole symbol may be printed from 80 percent to 200 percent of that standard, a module of 0.264 mm to 0.660 mm.
Height matters as much as width. GS1 sets the standard bar height of a UPC-A at 22.85 mm. It says cutting the bars shorter, called truncation, destroys omnidirectional scanning. That is because a short symbol only reads when the item is turned to the right angle. GS1 also says never to put a barcode or its clear space over a seam, fold, flap, perforation or tight curve.
The digits printed under the bars are for people, not scanners. GS1 says they are not meant to be machine read. Wikipedia credits Murray Eden at IBM with adding them as the fallback for when the reader fails.
What the scanner sends
Once the decoder has the digits it recomputes the last one, the check digit, from the others. GS1 says the reader carries out that verification automatically. Seagull Scientific's BarTender help describes a failed check as a silent miss: the scanner sends nothing and the cashier scans again. What that sum catches is in what a check digit is.
The output is the number, nothing more. Most scanners connect as a keyboard, so the digits appear wherever the cursor is. Some can add a three character prefix that names the symbol type, such as ]E0 for a UPC or EAN. The price, the product name and the stock count live in the retailer's system and are looked up by that number. A barcode holds no price, and it holds no circuit either, so it cannot trip a store's security gate. The guide on store alarms explains what does.
Grading a printed barcode
Retailers judge a barcode with a verifier. It is a measuring instrument that looks at the symbol the way a scanner does and reports a grade from 4 down to 0. GS1 asks for at least 1.5 for retail symbols, measured with a 0.15 mm aperture under 660 nm light, which it writes as 1.5/06/660. The grade is the average of the grades of several scan lines across the height of the symbol. A verifier does not check that the printed digits match the bars, so proofread those yourself.
Reading one by eye
The printed line under a UPC-A shows all 12 digits, with the first standing left of the bars and the last standing right of them. The first 6 to 10 digits are the company prefix, the next 1 to 5 the item reference, and the last the check digit. A UPC-E, the short symbol on small packs, shows 8 digits. Where the UPC code is on a product covers where to find it on bags, cans and books. The check digit tool tests a number you have read off a label.
The same idea extended to a grid is in what a 2D barcode is. The people who worked all this out are in who invented the barcode.
More about how barcodes work
Can a scanner read a barcode upside down?
Yes. The six digits on the left of a UPC use patterns with an odd number of dark columns. The six on the right use an even number. That lets the scanner tell which way it is reading and put the digits in order.
Why will my scanner not read red bars?
Because it reads with red light. GS1 US says red or reddish bars are invisible to a scanning laser. GS1 grades print quality under 660 nm red light for that reason. Black bars on white are the safe choice.
What does the scanner send to the computer?
The digits, usually as keyboard input, so the number lands wherever the cursor is. Some scanners add a short prefix such as ]E0 that names the barcode type. GS1 says the reader checks the last digit before it sends anything.
Is the price in the barcode?
No. The barcode holds the product number only. The till looks that number up in the store's database and returns the price. That is why one product can ring up at different prices in two stores.
7 source documents
- Seagull Scientific: BarTender help: check digit, fetched 2 November 2026
- GS1: General Specifications, Release 26.0, sections 5.1.3, 5.2, 5.12 and 6.3, fetched 2 November 2026
- GS1 US: Place barcodes on products, fetched 2 November 2026
- Zebra: What is a barcode?, fetched 2 November 2026
- IBM: The UPC, fetched 2 November 2026
- Wikipedia: Universal Product Code, encoding, fetched 2 November 2026
- Wikipedia: Barcode reader, fetched 2 November 2026