一维码不是「随便生成一串数字贴上去」。类型选错、校验位算错、静区被挤掉,条码就扫不出来。本文讲清 Code128 与 EAN-13 的选型逻辑、校验位原理、打印规范(最小尺寸、分辨率、静区),以及条码与二维码怎么取舍。
怎么选:内部资产 vs 零售
选型的第一问不是「哪种更好」,而是这条码会被谁扫。只有你自己组织的扫描系统读,还是外部系统(商超 POS、电商平台、图书馆)也要读?答案直接决定类型。
Code128:内部系统的万能码
Code128 支持大小写字母、数字、全部 ASCII 符号,长度理论上不限,同一个码里混编「ABC-00123」没问题。密度高、配合校验可靠,是仓库资产标签、工单、会员号、序列号、图书馆索书号的事实标准。内部用途几乎无脑选它。
EAN-13:零售商品的全球通行证
EAN-13 是固定 13 位纯数字的零售商品条码,结构是全球统一的:前缀(国家/地区)+ 厂商识别代码 + 商品项代码 + 1 位校验位。它的前提是你申请了 GS1 厂商识别代码——没有 GS1 前缀的「自制 EAN-13」不是合法零售码,进不了正规商超渠道。
| 维度 | Code128 | EAN-13 |
| 字符集 | 字母、数字、符号(ASCII) | 仅数字 |
| 长度 | 可变 | 固定 13 位 |
| 是否需申请 | 不需要 | 需要(GS1 前缀) |
| 典型场景 | 资产、工单、内部单据 | 零售商品、商超结算 |
| 校验方式 | 内置 mod 103 | 末位 mod 10 校验位 |
确定类型后,用本站 条形码生成器 直接生成——选类型、输入内容,校验位自动计算,全程浏览器本地完成,不上传任何数据。
校验位原理
校验位是印在条码末尾的一位「自检数字」:扫码器逐条解码后重新计算一遍,与读到的校验位比对,不一致就拒绝返回结果。它防的是误读——污损、掉墨、错位导致的读错一位,绝大多数会被校验拦下。
EAN-13 的 mod 10 算法
取前 12 位,从右往左依次乘以 3、1、3、1……求和后看个位:校验位 = (10 − 个位) mod 10。手算一遍最直观:
前 12 位:6 9 0 1 2 3 4 5 6 7 8 9
从右加权:×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3
= 6 +27 +0 +3 +2 +9 +4 +15 +6 +21 +8 +27
= 128 → 个位 8 → 校验位 = (10−8) mod 10 = 2
完整码:6901234567892
生成器会自动算校验位,但理解原理有两个实际好处:核对印刷品上的数字有没有被打错;排查「条码清清楚楚却扫不出来」时,先怀疑内容或校验位错了。
Code128 的内置校验
Code128 的校验不占可见字符——每个符号自带 mod 103 校验字符,编码时自动附加。你不用管它,只需知道:码越短越宽、越容易一次读对。
打印规范:尺寸、分辨率、静区
条码是硬边缘图形,屏幕上看着对,印出来常出问题。三个硬指标:
- 最小尺寸:EAN-13 标准尺寸 37.29×25.93 毫米,允许的最低放大系数 80%;Code128 窄单元不低于 0.19 毫米,建议 0.25 毫米以上。尺寸越小越难扫,别压线设计;
- 输出分辨率 ≥ 300 DPI:低分辨率打印会让最细的条发糊、粘连,直接读不出来。条件允许用矢量(PDF/SVG)输出最稳;
- 静区:条码两端必须留空白——EAN-13 左 11 模块、右 7 模块,Code128 至少 10 倍窄单元宽度。静区被文字、边框、裁切线侵入是排稿时最常见的翻车点;
- 颜色:条用深色、空和底用浅色,黑条白底最稳;不要用红色系做条(红色扫描器不识别),不要反白。
打印前用 条形码生成器 重新导出一份高分辨率版本,先打样实测再批量印刷——这一步和二维码印刷一样,永远不要省。
条码 vs 二维码
两者不是替代关系,是面向对象不同:
- 选条码:内容是一个短编号、由扫描枪批量识读、成本敏感(不干胶标签即可)、不需要人看懂——库存、资产、票务检票、零售结算;
- 选二维码:内容是网址或结构化数据、由消费者手机扫描、需要容错(破损仍可读)、要在码上叠 Logo——落地页、支付、名片、包装互动。
简单判断:机器读编号用条码,人扫码看内容用二维码。同一个包装上两者共存很常见——侧面印商品条码供结算,背面印二维码供互动。如果选了二维码,印刷排障和参数选择可参考 二维码扫不出来排查,静区与分辨率的讲究是相通的。
常见问题
Q:Code128 和 EAN-13 到底怎么选?
A:看用途:给顾客扫的商品零售码必须用 EAN-13(申请 GS1 前缀),系统只认标准商品编码;仓库资产、内部单据、会员卡、序列号等内部用途选 Code128——支持大小写字母、数字和符号,长度不限,密度也更高。简单说:进超市用 EAN-13,不进超市用 Code128。
Q:EAN-13 的校验位是怎么算的?
A:前 12 位从右往左交替乘以 3 和 1,求和后取「补到下一个 10 的倍数」的差:校验位 = (10 − 和的个位) mod 10。例如前 12 位加权求和得到 101,个位是 1,校验位就是 9。扫码器解码后会重算校验和,不一致就拒绝读取,所以校验位错一位,整条码就扫不出来。
Q:条形码最小可以印多小?
A:以 EAN-13 为例,标准尺寸是 37.29×25.93 毫米(放大系数 100%),规范允许的最低放大系数是 80%,再小扫描器就难以稳定识读。Code128 没有固定外形,但窄单元(最细的条或空)印刷时不低于 0.19 毫米、通常建议 0.25 毫米以上。尺寸越小,越要保证高分辨率打印和足够的静区。
Q:静区是什么?为什么条码总是被它「切断」?
A:静区是条码两端必须保留的空白带,EAN-13 左端约 11 个模块、右端约 7 个模块宽,Code128 一般要求窄单元宽度的 10 倍以上。扫码器靠静区判断条码从哪里开始和结束,排版时被文字、边框或裁切线挤占,就会出现「条码明明印得很清楚却扫不出来」。设计稿里给条码预留独立区域,不要让任何元素侵入静区。
Q:条码扫不出来怎么排查?
A:按命中率排查:先看静区是否被挤占,再检查打印分辨率是否达到 300 DPI(低分辨率会让细条发糊粘连),然后核对条码类型与内容是否匹配——比如把字母编进了只认数字的 EAN-13。最后用另一台扫描设备交叉验证,排除扫描器本身不兼容的情况。重新生成时逐字符核对内容,生成后立即实测。
Q:自己编的条码能用吗?什么时候需要申请 GS1 码?
A:内部用途随时可以自己编:Code128 编上资产编号、工单号,只要自己的扫描系统能识别就行。但只要条码要流出组织、被外部系统扫描——尤其是作为商品零售条码进入商超和电商平台——就必须申请 GS1 厂商识别代码,使用全球唯一的 EAN-13 编码。自己编的码撞上别人的商品码,会造成库存和结算混乱。
免费在线生成条形码
Code128 / EAN-13 · 校验位自动计算 · 高清 PNG · 纯浏览器本地生成
打开条形码生成器 →
Choosing: Internal Assets vs Retail
The first question isn't "which is better" but who will scan this barcode. Only your own systems, or external ones too (retail POS, marketplaces, libraries)? The answer decides the symbology.
Code128: the workhorse for internal systems
Code128 supports upper/lowercase letters, digits, and all ASCII symbols with virtually unlimited length — mixing "ABC-00123" in one code is fine. High density and reliable checks make it the de-facto standard for warehouse asset tags, work orders, membership numbers, serials, and call numbers. For internal use, pick it by default.
EAN-13: the global passport for retail
EAN-13 is a fixed 13-digit, numeric-only retail code with a worldwide structure: prefix (region) + manufacturer code + item reference + 1 check digit. It presumes a GS1 manufacturer prefix — a self-made "EAN-13" without one is not a legitimate retail code and won't be accepted by proper retail channels.
| Aspect | Code128 | EAN-13 |
| Charset | Letters, digits, symbols (ASCII) | Digits only |
| Length | Variable | Fixed 13 digits |
| Registration | Not required | Required (GS1 prefix) |
| Typical use | Assets, work orders, internal docs | Retail products, checkout |
| Check | Built-in mod 103 | Trailing mod-10 check digit |
Once you've picked a type, generate it with this site's Barcode Generator — choose the symbology, type the content, and the check digit is computed automatically, all locally in your browser.
How Check Digits Work
A check digit is a self-test digit at the end of the code: the scanner decodes each bar, recomputes the checksum, and rejects the result on mismatch. It guards against misreads — smudges, faded ink, and skew that flip a digit are mostly caught by the check.
The EAN-13 mod-10 algorithm
Take the first 12 digits, weight them alternately 3 and 1 from the right, sum them, then: check digit = (10 − last digit of the sum) mod 10. A worked example:
First 12: 6 9 0 1 2 3 4 5 6 7 8 9
Weights: ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3 ×1 ×3
= 6 +27 +0 +3 +2 +9 +4 +15 +6 +21 +8 +27
= 128 → last digit 8 → check = (10−8) mod 10 = 2
Full code: 6901234567892
Generators compute it for you, but knowing the mechanics pays off twice: you can spot a mistyped digit on a printed label, and when a "perfectly printed" code won't scan, a wrong check digit is a prime suspect.
Code128's built-in check
Code128's check isn't a visible character — every symbol carries a mod-103 check character appended automatically at encode time. Nothing to manage; just know that shorter, wider codes read right on the first pass more often.
Print Specs: Size, Resolution, Quiet Zone
Barcodes are hard-edged graphics — fine on screen, fragile in print. Three hard requirements:
- Minimum size: EAN-13 standard size is 37.29×25.93 mm with a minimum magnification of 80%; Code128 narrow elements should stay above 0.19 mm, ideally 0.25 mm+. Don't design at the limit — smaller means harder to scan;
- Output at ≥ 300 DPI: low resolution blurs and merges the narrowest bars, making the code unreadable. Vector output (PDF/SVG) is best when available;
- Quiet zone: keep blank margins at both ends — 11 modules left / 7 right for EAN-13, at least 10× the narrow element width for Code128. Quiet zones invaded by text, borders, or crop marks are the most common layout failure;
- Colors: dark bars on a light ground; black on white is safest. Avoid red bars (scanners skip red) and never invert.
Re-export a high-resolution copy from the Barcode Generator before printing, proof-test one copy, then run the batch — same rule as QR printing: never skip the live test.
Barcode vs QR Code
They don't replace each other — they address different audiences:
- Choose a barcode when the content is a short numeric ID read in bulk by scanners, cost-sensitive (plain labels), and not meant for humans — inventory, assets, ticketing, retail checkout;
- Choose a QR code when the content is a URL or structured data scanned by consumers' phones, when damage tolerance matters, or when you want a logo overlay — landing pages, payments, packaging interactivity.
Rule of thumb: machines reading IDs get barcodes; people scanning content get QR codes. Packaging often carries both — a product barcode on one side for checkout, a QR code on the back for engagement. If you go the QR route, see QR Code Not Scanning — the quiet-zone and resolution discipline carries over.
FAQ
Q: Code128 or EAN-13 — which one?
A: Depends on the use: retail codes scanned at checkout must be EAN-13 with a GS1 prefix — the retail system only accepts standard product codes. For warehouse assets, internal documents, membership cards, and serials, choose Code128: letters, digits, and symbols, unlimited length, higher density. In short: into supermarkets, EAN-13; not into supermarkets, Code128.
Q: How is the EAN-13 check digit calculated?
A: Weight the first 12 digits alternately by 3 and 1 from the right, sum them, then take the difference to the next multiple of ten: check digit = (10 − last digit of the sum) mod 10. If the weighted sum is 101, the check digit is 9. Scanners recompute the checksum and reject mismatches, so one wrong check digit makes the whole code unscannable.
Q: How small can a printed barcode be?
A: For EAN-13, the standard size is 37.29×25.93 mm (100% magnification) and the spec allows down to 80% — below that scanners struggle. Code128 has no fixed outline, but keep narrow elements above 0.19 mm, preferably 0.25 mm or more. The smaller the code, the more you need high-resolution printing and a proper quiet zone.
Q: What is the quiet zone, and why does it keep getting clipped?
A: The quiet zone is the mandatory blank margin at both ends — about 11 modules left and 7 right for EAN-13, or at least 10× the narrow element width for Code128. Scanners use it to find where the code starts and ends; when text, borders, or crop marks invade it, you get "clearly printed yet unscannable". Reserve a dedicated area in the layout and let nothing intrude.
Q: My barcode won't scan — how do I troubleshoot?
A: By hit rate: check the quiet zone first, then verify the print resolution reaches 300 DPI (low DPI blurs and merges narrow bars), then confirm symbology matches content — letters inside a digits-only EAN-13, for example. Finally cross-test with another scanner to rule out device incompatibility. Regenerate with the content verified character by character and test immediately.
Q: Can I just make up my own barcode? When do I need GS1?
A: For internal use, anytime: encode asset IDs and work orders in Code128 and your own scanners will read them. But once the code leaves your organization and gets scanned by external systems — especially as a retail code entering supermarkets and marketplaces — you must register a GS1 manufacturer code and use globally unique EAN-13 numbers. A collision with someone else's product code wrecks inventory and settlement.
Generate Barcodes — Free Online
Code128 / EAN-13 · Automatic check digits · Crisp PNG · Runs in your browser
Open Barcode Generator →