Barcodes look interchangeable at a glance — black and white lines of varying width — but the format underneath matters a lot depending on what you're labeling. Two of the most common linear (1D) barcode symbologies are Code128 and EAN-13, and they solve different problems.
EAN-13: retail product identification
EAN-13 is the format behind the barcode on almost every retail product you've ever scanned at a checkout. It encodes exactly 13 digits: a country/manufacturer prefix, a product code, and a single check digit at the end used to catch scanning or data-entry errors. Because it's a fixed-length numeric format tied to the GS1 global product numbering system, EAN-13 codes are meant to be globally unique identifiers for specific retail products — not arbitrary text.
Code128: flexible, alphanumeric, general purpose
Code128 is a different kind of symbology: it can encode the full ASCII character set (letters, digits, punctuation), making it suitable for shipping labels, internal SKUs, asset tags, serial numbers, or any situation where you need to encode more than just digits. Code128 comes in three character sets (A, B, and C); Set B — the most common for general text and mixed alphanumeric data — is what most barcode generators (including this one) implement first, since it covers standard printable ASCII.
How the checksum actually works
Both formats include a checksum digit to catch errors, but they compute it differently:
- EAN-13 uses a weighted sum over the first 12 digits, alternating weights of 1 and 3 by position, then takes
(10 − (sum mod 10)) mod 10as the check digit. For example, the 12-digit prefix400638133393produces a check digit of1, giving the full code4006381333931. - Code128 computes a weighted sum of each encoded character's value (multiplied by its position in the string, starting at 1), adds the start-code value, and takes the result mod 103 to get the checksum symbol — which is itself encoded as one more bar pattern before the stop symbol.
If either checksum doesn't match what a scanner computes from the bars it reads, the scan is rejected — this is what prevents a smudged or misprinted barcode from silently reading as the wrong product.
Choosing between them
- Labeling a retail product for sale, especially anything that needs to scan at a standard point-of-sale system → EAN-13
- Internal inventory tracking, shipping labels, asset tags, or anything with letters or mixed characters → Code128
- Need to encode a URL or long string? → Code128 (EAN-13 is numeric-only and fixed-length)
Generating barcodes correctly
A correct barcode generator needs to implement the actual bar-width pattern tables from the relevant ISO specification — ISO/IEC 15417 for Code128, ISO/IEC 15420 for EAN-13 — rather than inventing a similar-looking pattern, since scanners are matching against those exact specified widths. This tool implements both from the published specification tables, including the checksum math, and renders the result to a canvas you can export as a PNG for printing.
Whether you're setting up a small inventory system or just need a specific product code as a scannable image, understanding which symbology fits the job — and trusting that the checksum was computed correctly — makes the difference between a barcode that works at the register and one that just looks like one.
Frequently Asked Questions
Yes. Enter the 12-digit product code prefix and the tool calculates the correct check digit using the standard weighted mod-10 algorithm — you can also enter all 13 digits to verify an existing code.
This tool implements Code128 Set B, which covers standard printable ASCII (letters, digits, punctuation, and spaces) — suitable for shipping labels, asset tags, and general alphanumeric codes.
Yes — the Barcode Generator implements genuine Code128 and EAN-13 symbol encoding from the ISO specification tables, not an approximation. It's a one-time $6.99 purchase — no subscription, no account required.
Yes, the generated barcode renders to a canvas and can be downloaded as a PNG, ready to place in a label design or print directly.
EAN-13 is for standard 13-digit retail product codes with a fixed numeric format; Code128 is more flexible and can encode letters, numbers, and punctuation for inventory, shipping, or asset labels.