惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
B
Blog
罗磊的独立博客
GbyAI
GbyAI
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
The GitHub Blog
The GitHub Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Barcode Density Matters More Than You Think: Code 128 vs ...
swift king · 2026-06-24 · via DEV Community

swift king

I spent three years running inbound at an Amazon sort center, and I've watched barcodes fail in ways that textbook comparisons never cover. Here's what actually matters when you're choosing between Code 128 and Code 39.

The Real Difference: Bar Width Count

Code 128 uses four different bar widths. Code 39 uses two (narrow and wide). That's the entire game — everything else follows from this one design decision.

// Code 39: Simple wide/narrow ratio
const CODE39_BAR_WIDTHS = { narrow: 1, wide: 2.5 };

// Code 128: Four precise widths
const CODE128_BAR_WIDTHS = [1, 2, 3, 4];

This is why Code 128 packs 40-50% more data into the same space. But it's also why Code 39 survives a forklift running over your label.

When Density Wins

If your label is smaller than 2 inches wide and you need 12+ digits, Code 128 is the only option that fits at scanner-readable resolution. I learned this the hard way with a cosmetics client who needed barcodes on lipstick tubes — Code 39 at that size was unreadable. Code 128 at 0.15mm narrow bar width scanned perfectly on the first try.

// The density math
const code128Density = 0.15; // mm per narrow bar
const code39Density = 0.19;  // mm minimum

// For a 12-digit GTIN:
const code128Width = 12 * 11 * code128Density; // ~19.8mm
const code39Width = 12 * 16 * code39Density;   // ~36.5mm — nearly double

When Durability Wins

Code 39 only needs to distinguish "wide bar" from "narrow bar." When a label gets smeared with hydraulic fluid or rain-soaked, the scanner can still tell the difference because the ratio only needs to be approximately 2.5:1.

Code 128's four-width scheme means a smudge that turns a width-2 bar into a width-3 bar produces a completely wrong character. There's no "approximately" — it reads a different barcode entirely.

My Production Setup

After three years of watching both formats succeed and fail:

  • For anything that ships out: Code 128 on GS1-compliant labels. Your supply chain partners expect it.
  • For anything that stays in the building: Code 39, printed large. It'll survive conditions that would make a Code 128 label illegible.

The $29 USB barcode scanner reads both fine. The beat-up Symbol LS2208 someone dropped off a mezzanine reads both fine. Scanner compatibility hasn't been a meaningful differentiator since 2010. The difference is density vs durability, and which side you need depends entirely on where the label lives.

For generating clean barcodes in any format, I use genbarcode.org — a free browser-based tool that handles the technical details so you don't have to.