跳到主内容
UniKit

条形码生成

自研编码器在线生成 EAN-13、UPC-A、Code 128(Code B/C 自动切换)与 Code 39 条形码:自动补校验位并校验,实时预览,输出纯 SVG 字符串可复制或保存为 .svg 文件。

浏览器本地运行所有计算都在你的浏览器里完成,数据不会离开本机。

条形码内容

编码器完全自研,不依赖任何第三方库,也不会上传数据:EAN-13 / UPC-A 按 GS1 General Specifications,Code 128 按 ISO/IEC 15417,Code 39 按 ISO/IEC 16388。

在条码下方显示文字

预览

4006381333931
编码文本4006381333931
模块数95
静区(左 / 右)11 / 7
SVG 源码
<svg xmlns="http://www.w3.org/2000/svg" width="226" height="100" viewBox="0 0 226 100" role="img" aria-label="ean13 4006381333931" shape-rendering="crispEdges"><rect width="226" height="100" fill="#ffffff"/><g fill="#000000"><rect x="22" y="0" width="2" height="80"/><rect x="26" y="0" width="2" height="80"/><rect x="34" y="0" width="4" height="80"/><rect x="40" y="0" width="2" height="80"/><rect x="44" y="0" width="2" height="80"/><rect x="50" y="0" width="6" height="80"/><rect x="58" y="0" width="2" height="80"/><rect x="62" y="0" width="8" height="80"/><rect x="72" y="0" width="8" height="80"/><rect x="82" y="0" width="2" height="80"/><rect x="90" y="0" width="2" height="80"/><rect x="96" y="0" width="2" height="80"/><rect x="100" y="0" width="4" height="80"/><rect x="108" y="0" width="4" height="80"/><rect x="114" y="0" width="2" height="80"/><rect x="118" y="0" width="2" height="80"/><rect x="122" y="0" width="2" height="80"/><rect x="132" y="0" width="2" height="80"/><rect x="136" y="0" width="2" height="80"/><rect x="146" y="0" width="2" height="80"/><rect x="150" y="0" width="2" height="80"/><rect x="160" y="0" width="2" height="80"/><rect x="164" y="0" width="6" height="80"/><rect x="172" y="0" width="2" height="80"/><rect x="178" y="0" width="2" height="80"/><rect x="188" y="0" width="2" height="80"/><rect x="192" y="0" width="4" height="80"/><rect x="200" y="0" width="4" height="80"/><rect x="206" y="0" width="2" height="80"/><rect x="210" y="0" width="2" height="80"/></g><text x="113" y="95" text-anchor="middle" font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="13" fill="#000000">4006381333931</text></svg>

这个工具能做什么

  • 给商品做条码标签:输入 12 位 EAN-13 前缀,工具自动补上校验位并校验,导出的 SVG 可直接放进包装设计稿。
  • 把一串数字变成能扫的码:仓库货位、资产编号用 Code 128,数字串会自动切到 Code C,条码更短更好扫。
  • 验证校验位:拿到别人给的 EAN-13 / UPC-A 时先在这里跑一遍,位数或校验位不对会立刻报错,省得打印出来才发现扫不出。
  • 做内部单据或物流面单:Code 39 兼容性好、印刷容错高,适合小批量自制标签。

示例

输入

码制 EAN-13,内容 4006381333931,模块宽度 2 像素,条高 80 像素

输出

编码文本 4006381333931,模块数 95,静区 11 / 7,SVG 画布 226 × 100 像素,图案以 101 开头、101 结尾

输入 12 位(400638133393)时会自动补上校验位 1;输入 13 位时校验位必须正确,否则提示校验位错误。

常见问题

生成的条码能直接打印使用吗?

可以,但要注意三点:模块宽度不要小于 0.264mm(GS1 对 EAN-13 的最小尺寸要求),左右静区必须保留(工具已经把它们算进画布宽度),打印时不要缩放成非整数倍。建议先打一张用扫码枪实测。

EAN-13 和 UPC-A 有什么区别?

两者结构几乎一样,都是 95 个模块、共用 L/G/R 码字表,区别在位数与校验位权重:EAN-13 是 12 位数据 + 1 位校验(奇数位权重 1、偶数位权重 3),UPC-A 是 11 位数据 + 1 位校验(奇数位权重 3、偶数位权重 1)。EAN-13 首位是 0 时可以看作 UPC-A。

Code 128 的 Code B / Code C 是怎么选的?

连续 4 位以上数字会自动切到 Code C(两位数字压成一个码字,条码更短),遇到非数字再切回 Code B;如果数字串长度是奇数,会先用 Code B 编掉一位再切,保证 Code C 始终成对处理数字。

为什么 Code 39 只支持大写字母?

Code 39 的字符集就是数字、大写字母和 - . 空格 $ / + % 共 43 个字符,没有小写字母。输入小写会自动转成大写,输入其它字符会直接报错,避免生成一张扫不出原值的码。

内容会被上传或保存吗?

不会。编码、校验和 SVG 生成全部在浏览器里完成,页面不发任何请求,也没有服务端存储;关闭页面后内容即消失。

关键词:barcode generatorean 13upc acode 128code 39svg barcodecheck digit条形码生成条形码在线生成EAN13校验位Code128条形码UPC条形码

同类工具