fixmint

Which barcode to use: EAN-13, UPC-A, Code 128 or Code 39

By · · 4 min read

The right barcode depends on who scans it. A product sold in shops needs an EAN-13, UPC-A or EAN-8 number, and those numbers belong to the company that owns the brand, issued through GS1. Shops check them. For your own labels, stock, shipping or events, Code 128 is the usual choice, and Code 39 is the older format that almost every scanner still reads. Every EAN and UPC number ends with a check digit that catches misreads, and the barcode generator works it out for you.

Barcode generatorNeed a barcode for a productOpen

Retail codes: EAN-13, UPC-A and EAN-8

EAN-13 is the 13-digit code printed on packaged goods in shops. UPC-A is a 12-digit code, used mainly in North America. It is the EAN-13 layout with a leading zero that is not printed, so its bars are the same as an EAN-13 with that zero in front. EAN-8 is the short form for very small packs, with 8 digits in all.

Retail numbers come from GS1, the organisation that issues company prefixes, and the brand owner assigns product numbers under them. A number invented for a product you do not own can clash with a real product, and shops check the numbers they scan. Use these codes only for products that carry them legitimately. Use Code 128 for everything inside your own business.

The field label changes with the type, and it shows how many digits to type:

TypeWhat you typeDigits printed
EAN-1312 digits, or 13 with the check digit13
UPC-A11 digits, or 12 with the check digit12
EAN-87 digits, or 8 with the check digit8
Code 128any printable charactersthe text you typed
Code 39A–Z, 0–9, space and - . $ / + %the text you typed

Spaces and hyphens in an EAN or UPC number are ignored, so 400-638-133393 and 400638133393 are the same input.

Code 128 and Code 39 for your own codes

Code 128 holds letters, digits and symbols, so it suits stock numbers, shipping references and internal labels. The generator accepts any printable character. It refuses tabs and line breaks with the message "Code 128 takes printable characters only: no tabs or line breaks."

Code 39 is older and wider. It takes only capital letters A to Z, the digits 0 to 9, a space and the symbols - . $ / + %. Lowercase letters are turned into capitals, so ab-1 becomes AB-1. The generator adds no check character for Code 39, so the code itself cannot catch a misread. Keep the text short and check the printed label against the record.

The check digit, worked through

The check digit is calculated from the other digits. For EAN and UPC numbers, the rule is a mod-10 check. Multiply the digits alternately by 3 and by 1, add the products, and take the amount needed to reach the next multiple of 10. The generator uses the same rule, with weight 3 on the digit next to the check digit.

Take the 12 digits 400638133393. Counting from the left, the weights alternate 1 and 3, so the last digit has weight 3:

PositionDigitWeightProduct
1414
2030
3010
46318
5313
68324
7111
8339
9313
10339
11919
12339
Total89

The total of 89 leaves 9 when divided by 10, so the check digit is 10 − 9 = 1. The full EAN-13 is 4006381333931. Under the bars, the generator prints 4 006381 333931, with the check digit as the last digit.

Typing a wrong last digit, such as 4006381333932, gives the message "The check digit should be 1". Typing the correct 13 digits is accepted. The same rule gives the UPC-A check digit for 03600029145, which is 2, and the EAN-8 check digit for 9638507, which is 4. The generator prints 036000291452 and 96385074 for those.

Printing so it scans

  • Quiet zones. A barcode needs clear space on each side. The generator adds it automatically: 11 modules on the left and 7 on the right for EAN-13, 9 on each side for UPC-A, 7 on each side for EAN-8, and 10 on each side for Code 128 and Code 39. A module is the width of the narrowest bar. Keep text, borders and colour out of that space.
  • Bar height. The generator offers Short, Normal and Tall bars. Taller bars give a hand scanner more to aim at.
  • Contrast. The generator draws black bars on a white background. A barcode printed in a light ink, or in a coloured ink on a coloured sticker, may not scan. Use dark bars on a light background.
  • No stretching. Scale the barcode only in proportion. A barcode stretched sideways or squashed changes the widths of its bars, which can stop it scanning.
  • SVG or PNG. The SVG is made of exact rectangles and stays sharp at any size, so it is the better file for print. The PNG is drawn with whole pixels per module, at Small (2 pixels per module), Medium (3) or Large (5). Choose Large before you download a PNG for print.
  • Show text. Keep Show text ticked to print the digits under the bars. If a scanner fails, a person can key in the number.

Two-dimensional codes follow different rules. The QR code generator makes those, and why a QR code will not scan covers their quiet zone and contrast.

Edge cases

  • Changing a number. A printed barcode cannot be edited. If the number is wrong, print a new label.
  • Copying the number. The Copy number button copies the full number with its check digit. For Code 128 and Code 39 it copies the text you typed.
  • Records. A barcode holds only a number. Keep a separate record of which item each number belongs to.
Cover of The Paperoom Game Night KitThe Paperoom Game Night Kit

A 52-page printable game night: party bingo, puzzles, board games and pencil-and-paper battles, plus planner and scoreboards.

$7.00 Get it on Gumroad →