条码生成器

输入一个 GTIN,得到可直接付印的条码。校验位会先被校验 —— 一个编码了错误号码的条码,比没有条码更糟。

🔒 你的数据不会离开浏览器 —— 符号在本地生成,不是从服务器取来的。

条码是怎么把号码编进去的

一个 EAN-13 符号宽 95 个模块。其中 3 个是起始符,5 个是中间分隔符,3 个是终止符;余下的 84 个用每 7 个模块承载一位,编入 12 位可见数字。而第 13 位 —— 也就是你看到印在最前面的那一位 —— 根本没有被画出来。

它编码在左半部分的奇偶模式里:左边 6 位数字各自用两张编码表中的一张来画,而每一位用了哪张表,拼起来就是首位数字。这就是 EAN-13 能把 13 位塞进 12 位条空里的原因,也是扫描器无论从哪个方向读都能判断出正反的原因。

为什么要先校验校验位再画

一个你输什么就画什么的条码生成器,会痛快地给你一张扫出来是另一件商品、或者干脆扫不出的标签。既然校验位是由其余各位推导出来的,对不上就意味着其中某一位错了 —— 所以本工具会停下来告诉你正确的号码,而不是把这个错误印上几千份。

怎么印才真的扫得出

我们凭什么确信编码是对的

编码表很容易抄错,而且靠肉眼看不出来。我们的测试套件里有一个独立编写的解码器:每次构建都会编码几千个随机码再解回来,编码表里任何一处错误都会立刻打断这个往返。标准的结构性规则 —— 奇偶校验集、每位四段、EAN-13 的 95 个模块 —— 也逐条断言。

本工具在什么情况下拒绝出图(共 5 条规则)

BAR-I01 只能是数字

这几种码制只编码十进制数字,别的都不行。输入里出现字母、空格或连字符,通常意味着复制时把格式一起带过来了,或者它压根不是一个 GTIN。

修复: 把非数字的字符全部去掉,然后重新核对位数。

来源: Derived from the module-encoding tables of each symbology, which this package implements and self-proves: the generator ships an independent decoder, and our tests round-trip thousands of random values through encode and decode to show the tables are right.

BAR-L01 位数必须对得上某一种码制

号码的位数决定用哪种码制:EAN-13 取 13 位,UPC-A 取 12 位,EAN-8 取 8 位,ITF-14 取 14 位。其他位数没法画成这几类线性条码。

修复: 先看看是不是丢了前导零 —— 11 位的值极常见地是被表格软件剪掉一位的 UPC-A。

来源: Derived from the module-encoding tables of each symbology, which this package implements and self-proves: the generator ships an independent decoder, and our tests round-trip thousands of random values through encode and decode to show the tables are right.

BAR-C01 校验位必须正确

校验位对不上时,生成器拒绝出图。这是最要紧的一条:用错号码画出来的条码扫起来毫无异常,只是解析成了另一件商品 —— 或者什么都不是 —— 而你要等它印上包装之后才会发现。

修复: 在生成之前重算校验位,而不是在印刷之后。

来源: Derived from the module-encoding tables of each symbology, which this package implements and self-proves: the generator ships an independent decoder, and our tests round-trip thousands of random values through encode and decode to show the tables are right.

BAR-Q01 静区是条码的一部分

条杠两侧的空白边距不是装饰 —— 扫描器靠它找到码的起点和终点。渲染出来的图形已经把静区包含在内,所以一张紧贴条杠裁切的条码,即使看着完整,也会读得不稳。

修复: 把图形放进版面时,保留它四周的留白。

来源: Derived from the module-encoding tables of each symbology, which this package implements and self-proves: the generator ships an independent decoder, and our tests round-trip thousands of random values through encode and decode to show the tables are right.

BAR-S01 这套编码是自证的

把数字变成条杠的模块表,是生成器唯一可能悄悄出错的地方 —— 因为一张错的表照样能画出看着很像样的条码。本包自带一个独立的解码器,测试里拿随机值走一遍编码再解码,所以这些表是被证明过的,不是假定正确的。

来源: Derived from the module-encoding tables of each symbology, which this package implements and self-proves: the generator ships an independent decoder, and our tests round-trip thousands of random values through encode and decode to show the tables are right.

一个你输什么它就画什么的生成器,比一个会报错的危险得多 —— 因为错误要等到包装印完之后才会被发现。以下就是本工具拒绝出图的条件。

关于这些规则。 每一条都有编号、严重级别和通俗解释。每个来源链接都已登记在案,并对线上页面实际复验过,而不是凭印象写上去的. 规则如何编写、测试与保持更新 →

下载的 SVG 里带有一行 XML 注释,标明它的出处(<!-- Generated by yaktool.com -->)。它不可见,不影响符号的扫描与打印,PNG 下载则完全不带 —— 但你应当知道它在那里,也可以用任何文本编辑器把这一行删掉。