The Sneaky Way EAN-13 Barcodes Hide Their First Digit
Published 2026-09-14
13 digits, but only 12 get drawn
Every EAN-13 barcode — the kind on the back of every published book — encodes 13 digits. Look closely at how it's built, though, and you'll find only 12 of those digits are directly drawn as bar patterns: six on the left half, six on the right. The very first digit is encoded differently, and more cleverly.
Two "alphabets" for the same digits
Each of the ten digits (0–9) actually has two different possible bar patterns it can be drawn as on the left half of the barcode, called the L-code and G-code sets (a third set, R-code, is reserved for the right half). Which of the two sets each of the six left-hand digits uses isn't arbitrary — it follows one of ten fixed sequences, like LLGLGG or LGGLLG, and each of those ten sequences corresponds to exactly one possible first digit. A scanner reads which pattern set each left-hand digit used, decodes the resulting L/G sequence back to a single digit, and that's the barcode's true first digit — without it ever being drawn as its own set of bars.
Why bother with this at all?
This design isn't just cleverness for its own sake: because the R-code (right half) patterns are the bitwise opposite of L-code patterns, and G-code is different again, a scanner can tell instantly whether it's reading a barcode left-to-right or upside-down right-to-left, just from which pattern types it sees where. That's the whole reason self-checkout scanners work no matter which way you wave a barcode past them.
Generate a correct one yourself
Our ISBN/EAN-13 Barcode Generator implements this exact encoding — start guard, six L/G-coded left digits, middle guard, six R-coded right digits, end guard — and was checked against a published real-world EAN-13 example before release, so the barcode it draws is genuinely scannable, not just visually barcode-shaped.