About

Tool No. 36 of Pikkola

A barcode is a written agreement: this width means one, that width means zero, and a scanner somewhere else will read it the same way. This page writes those widths from the published tables, without a library, and shows you the arithmetic behind the last digit.

What it does

How a symbol is built

Every format here reduces to a string of modules, one character per module, dark or light. EAN-13 is 95 modules: three for the start guard, forty-two for the six left digits, five for the centre guard, forty-two for the six right digits, and three for the end guard. The first digit is not drawn at all; it chooses which parity pattern the six left digits are written in, and that is how the scanner learns it.

Code 128 starts from the published table of 107 width patterns, each eleven modules wide. The encoder picks set C for runs of digits and set B or A otherwise, so a number such as an invoice reference ends up nearly half the length it would take in Code 39. A modulo 103 checksum follows the data, then a thirteen-module stop pattern.

ITF-14 interleaves two digits into one group of five bars and five spaces, which is why a wide bar can sit beside a wide space and why the symbol looks coarser than the rest. Code 39 uses nine elements per character with exactly three wide, a gap of one narrow space between characters, and an asterisk at each end that is part of the symbol rather than of the value.

The check digit, by hand

Take an EAN-13 and drop the last digit. Number the remaining twelve from the left, multiply the odd positions by 1 and the even positions by 3, and add. For 880123456789 the sum is 127. The check digit is what is left when you take the next multiple of ten, 130, and subtract: 3. If the printed last digit is anything else, the code is wrong before it is ever scanned, and this page says so.

UPC-A uses the same weights starting from a different end, EAN-8 and ITF-14 the same idea over a different count. ISBN-13 is an EAN-13 whose first three digits are 978 or 979, so the arithmetic is identical and only the prefix changes meaning.

What it deliberately does not do

Why it is free

Pikkola builds small tools that do one job and keeps them free, with no account and no advertising. A static page that draws rectangles in the browser costs almost nothing to serve, so there is no reason to charge for it.

Contact

A symbol that will not scan, a phrase that reads badly in Korean or Japanese, a format you need and do not see: hello@pikkola.com. Tell us the format, the value and what the scanner did.

Back to the studio