Code 128 vs EAN-13: Choosing the Right Barcode Format
What Code 128 and EAN-13 encode, how check digits work, when you need GS1 numbers, and the print sizes that make each scan reliably.
Code 128 vs EAN-13: use EAN-13 for retail products scanned at checkout. It has a fixed 13-digit format and needs a GS1-issued number. Use Code 128 for internal uses such as employee IDs, asset tags, tickets and shipping labels, because it encodes letters, numbers and symbols compactly and needs no registration.
- EAN-13: retail products, exactly 13 digits, GS1-issued numbers required
- Code 128: internal IDs, assets, tickets and labels; letters, numbers and symbols
- Both are read by virtually all 1D barcode scanners
- Check digits make scanners reject misreads instead of returning wrong data
- Keep quiet zones clear and do not shrink barcodes below their minimum size
What is the difference between Code 128 and EAN-13?
EAN-13 is a fixed-length, numbers-only retail barcode for identifying products worldwide. Code 128 is a flexible, variable-length barcode that can encode any text, used for everything from employee badges to shipping labels.
At a glance
- Characters: EAN-13 encodes digits only; Code 128 encodes all 128 ASCII characters (letters, digits, punctuation and control characters).
- Length: EAN-13 is always 13 digits; Code 128 is variable, though very long values make the barcode wide.
- Numbering: EAN-13 numbers come from GS1 and identify a specific product; Code 128 content is whatever you choose.
- Check value: EAN-13 has a mod-10 check digit printed as the last digit; Code 128 has a hidden mod-103 check character.
- Typical use: EAN-13 is for products at checkout; Code 128 is for IDs, assets, tickets, libraries and logistics.
The one-line rule
If a shop's till will scan it, use EAN-13 (or UPC-A in the US and Canada). For anything else, Code 128 is usually the better choice.
Both can be made with the CardDeck barcode generator, which calculates the EAN-13 check digit for you and exports SVG for sharp printing.
How does EAN-13 work?
EAN-13 encodes 12 data digits plus one check digit. The data digits come from a GS1 company prefix assigned to your business, followed by an item reference you assign to each product.
Structure of an EAN-13 number
- GS1 prefix (first 2 or 3 digits): identifies the GS1 member organization that issued the number. It indicates where the company prefix was registered, not where the product was made.
- Company prefix (continues from the GS1 prefix): identifies your company. Its length depends on how many products you need to number.
- Item reference: the digits you assign to each product variant.
- Check digit (last digit): calculated from the other 12.
EAN-13 and UPC-A
UPC-A is the 12-digit format used mostly in the US and Canada. A UPC-A number is equivalent to an EAN-13 number with a leading zero, and modern retail scanners read both. If you sell mainly in North America, your retailer may ask for UPC-A; the UPC-A barcode generator handles that format.
Why you cannot invent EAN-13 numbers
Retailers and marketplaces check that product numbers belong to the company selling the product. Numbers you make up, or buy from unofficial resellers, may clash with real products or be rejected. Register with your local GS1 organization to get a company prefix. CardDeck generates the barcode from the number you provide; it does not issue GS1 numbers.
How does Code 128 work?
Code 128 encodes text using three character sets and switches between them to keep the barcode short. It supports all 128 ASCII characters and includes a hidden check character.
The three code sets
- Code Set A: uppercase letters, digits, punctuation and control characters.
- Code Set B: uppercase and lowercase letters, digits and punctuation. The usual set for mixed text.
- Code Set C: pairs of digits, encoded two per symbol character. This makes long numbers very compact.
A good generator chooses and switches sets automatically, so an ID like NWL-0428 or a long numeric shipping reference comes out as short as possible.
GS1-128
GS1-128 is a use of Code 128 with special data formatting (application identifiers) for supply chain information such as batch numbers, expiry dates and serial shipping container codes. If a logistics partner asks for GS1-128, they mean Code 128 with that structure.
Typical Code 128 uses
- Employee and student ID numbers on cards.
- Asset tags for laptops, tools and equipment.
- Library cards and membership numbers.
- Tickets and wristbands.
- Internal shipping and warehouse labels.
The Code 128 barcode generator creates one barcode at a time or one per row from a spreadsheet.
How is a barcode check digit calculated?
A check digit is a number calculated from the rest of the data. The scanner recalculates it on every read; if the result does not match, the read is rejected instead of returning a wrong number.
Worked example: EAN-13
Take the 12 data digits 5 9 0 1 2 3 4 1 2 3 4 5.
- Multiply each digit by alternating weights of 1 and 3, starting with 1 on the left: 5×1, 9×3, 0×1, 1×3, 2×1, 3×3, 4×1, 1×3, 2×1, 3×3, 4×1, 5×3.
- That gives 5, 27, 0, 3, 2, 9, 4, 3, 2, 9, 4, 15.
- Add them: the total is 83.
- Find the amount needed to reach the next multiple of 10: 90 minus 83 is 7.
- The check digit is 7, so the full number is 5901234123457.
If the total is already a multiple of 10, the check digit is 0.
Code 128 check character
Code 128 uses a modulo-103 checksum. Each symbol's value is multiplied by its position, added to the start character's value, and the total divided by 103; the remainder becomes the check character. It is not printed as a readable digit, and you never type it; the generator adds it.
Why this matters to you
You should never have to calculate a check digit by hand. But if someone hands you a 13-digit number, recalculating the last digit is a quick way to spot a typo before printing thousands of labels.
When should you use EAN-13?
Use EAN-13 when a product will be sold through retailers, supermarkets or marketplaces that scan barcodes at checkout or require a GS1 identifier for listings.
Good uses
- Consumer products in shops anywhere outside North America, and increasingly within it.
- Products listed on marketplaces that require a GS1 product identifier.
- Books and magazines, which use EAN-13 in the form of ISBN and ISSN-based numbers.
Before you print
- Get a GS1 company prefix and assign item references.
- Generate the barcode from the full number, letting the tool calculate the check digit.
- Place it on a flat area of the packaging, away from folds, seams and curved edges where possible.
- Print a sample and test it with a real scanner.
When EAN-13 is the wrong choice
- Internal stock codes that never leave your business. Use Code 128 instead; you do not need GS1 numbers.
- Anything with letters, such as an employee ID. EAN-13 is digits only.
- Variable-length references. EAN-13 must always be exactly 13 digits.
Retailers with inventory and asset needs often use both formats; see barcodes for retail and inventory.
When should you use Code 128?
Use Code 128 for any barcode that will be read inside your own organization or by partners who agree on the format: IDs, assets, tickets, libraries and logistics.
Good uses
- Employee and student IDs: encode the ID number, such as NWL-0428, for access readers, canteen tills or library systems.
- Asset tags: laptops, tools and furniture, scanned during audits.
- Membership cards at front desks with 1D scanners.
- Tickets and wristbands where the reader is a 1D scanner.
- Internal stock and bin locations in a warehouse.
Tips for Code 128
- Keep values short. Every character adds width. An ID of 6 to 12 characters fits comfortably on an ID card.
- Numeric-only values are especially compact because of Code Set C.
- Avoid characters you do not need, like spaces and lowercase letters, if your scanner system is case-sensitive.
- Use the same format for every record so scans are predictable, for example a fixed prefix plus a number.
Generating them in bulk
For hundreds of asset tags or IDs, put the values in a spreadsheet column and use the bulk barcode generator to create one barcode per row as SVG, PNG or a print-ready label sheet.
What size should Code 128 and EAN-13 barcodes be printed?
Print barcodes large enough for your scanner, keep the quiet zones clear and never squash the height. The specs below are the safe defaults.
EAN-13 sizing
- The nominal (100%) EAN-13 symbol is about 37.3 mm wide (including quiet zones) and about 25.9 mm tall (including the digits), with a narrowest bar (module) of 0.33 mm.
- GS1 allows printing between 80% and 200% of nominal size for general retail scanning. Below 80%, scanning becomes unreliable.
- Quiet zones: 11 modules on the left and 7 on the right, with no text, lines or edges intruding.
- Do not truncate (cut down) the bar height to fit a design; retail guidelines discourage it.
Code 128 sizing
- Size depends on the length of the data and the narrowest bar width (X-dimension), so there is no single fixed size.
- Keep the quiet zone at least 10 times the X-dimension on each side.
- Keep the bar height generous. A common rule is at least 15% of the barcode's width, or 6.35 mm (0.25 in), whichever is greater.
- Test the smallest size your scanner reads reliably and stay above it.
Print quality
- Black bars on a white background are safest. Avoid red bars: many scanners use red light and cannot see them.
- Use vector SVG or high-resolution output so edges stay sharp.
- Avoid placing barcodes on curved surfaces, folds or glossy areas that glare.
What mistakes should you avoid with barcodes?
Most barcode failures come from the wrong format, a made-up number, or printing that ignores size and quiet zones. Check these before a large print run.
Common mistakes
- Making up EAN-13 numbers for retail products instead of using GS1-issued numbers.
- Using EAN-13 for internal codes that contain letters or vary in length. Use Code 128.
- Using a QR code where a till expects a 1D barcode. Our barcode vs QR code guide covers when each fits.
- Squashing or stretching a barcode image to fit a space. Resize proportionally.
- Crowding the quiet zones with text, borders or the edge of a label.
- Low contrast: gray on gray, colored bars or busy backgrounds.
- Using a barcode font without encoding. Code 128 fonts need start, stop and check characters added first, or the result will not scan.
- Not testing with the real scanner before printing thousands of labels.
Pre-print checklist
- Right format for the reader: EAN-13 or UPC-A at checkout, Code 128 internally.
- Number verified, check digit correct.
- Size at or above minimum; quiet zones clear.
- Dark bars on light background.
- Printed sample scanned successfully.
FAQ
Can I use Code 128 on retail products?
Not for checkout scanning. Retailers expect EAN-13 or UPC-A with GS1-issued numbers. Code 128 is fine for internal labels, shipping cartons in GS1-128 form, and anything not scanned at a till.
Do I need GS1 membership to use EAN-13?
To sell products through retailers you need GS1-issued numbers, which come with GS1 membership. CardDeck generates the barcode from the number you provide but does not issue numbers.
Can Code 128 encode letters?
Yes. Code 128 encodes all 128 ASCII characters, including uppercase and lowercase letters, digits and punctuation. EAN-13 encodes digits only.
What is the difference between EAN-13 and UPC-A?
UPC-A has 12 digits and is used mainly in the US and Canada. EAN-13 has 13 digits and is used worldwide. A UPC-A number is equivalent to an EAN-13 number with a leading zero.
Is the CardDeck barcode generator free?
Yes. Static barcodes, including Code 128 and EAN-13, are unlimited on every plan, including Free, and download as SVG for print.
Why will my barcode not scan?
The usual causes are a crowded quiet zone, printing too small, low contrast, a squashed image or, for font-based Code 128, missing start, stop or check characters. Regenerate the barcode at a larger size and test again.