Code 39 Barcode Generator & Code 128
Make a scannable Code 39 barcode (with optional mod 43 check digit) or a Code 128 barcode from your text, then download or copy it as a PNG. Everything runs in your browser — no data is sent to any server.
A Code 39 barcode (also called Code 3 of 9) is a variable-length, self-checking linear barcode that encodes 43 characters: digits 0-9, uppercase A-Z, space and - . $ / + %. Every symbol starts and ends with an asterisk (*), and each character is drawn as nine elements — five bars and four spaces, three of them wide.
Code 39 Barcode Character Set and Structure
Code 39 is specified internationally by ISO/IEC 16388 (and in the US by ANSI/AIM BC1 "USS Code 39"), according to the Barcode Writer in Pure PostScript Code 39 reference. Because every character uses exactly three wide elements out of nine, a scanner can detect a misread character on its own. Wide elements are typically 2 to 3 times the narrow width; this generator uses 3:1 and puts one narrow space between characters. Lowercase input is converted to uppercase automatically. The optional mod 43 check digit adds the value of every data character (0-9 = 0-9, A-Z = 10-35, - = 36, . = 37, space = 38, $ = 39, / = 40, + = 41, % = 42), divides by 43 and appends the character for the remainder:
| Step | Example: "CODE39" |
|---|---|
| Character values | C=12, O=24, D=13, E=14, 3=3, 9=9 |
| Sum of values | 12 + 24 + 13 + 14 + 3 + 9 = 75 |
| Sum mod 43 | 75 mod 43 = 32 |
| Check character | Value 32 = W |
| Symbol with start/stop | *CODE39W* |
Where Code 39 Is Used
Code 39 is older and less dense than Code 128, but it is still required by several long-running standards. The US Department of Defense uses it as LOGMARS under MIL-STD-1189, and a HIBC Code 39 variant exists for health-industry labels (both listed in the Code 39 reference). Automotive suppliers meet it on parts and shipping labels built to AIAG labeling standards. It is also common on employee ID badges, library cards, asset tags and internal inventory labels because almost every scanner reads it out of the box.
If you print with a Code 39 font instead of an image, the font maps the asterisk to the start/stop pattern, so you must type the data as *ABC123*. The Copy button on this page gives you that asterisk-wrapped text, including the check digit when enabled.
Code 39 vs Code 128 vs UPC-A
Pick the symbology your scanner, customer or label spec asks for. Sources: Code 39, Code 128 and UPC-A references.
| Feature | Code 39 | Code 128 | UPC-A |
|---|---|---|---|
| Characters | 43: 0-9, A-Z, space, - . $ / + % | Full ASCII | Digits only |
| Length | Variable | Variable | Fixed: 12 digits (GTIN-12) |
| Check digit | Optional (mod 43) | Always (mod 103) | Always (last digit) |
| Density | Low — longest barcode | High — shortest for text | Fixed size |
| Standard | ISO/IEC 16388 | ISO/IEC 15417 | ISO/IEC 15420, GS1 |
| Typical use | Defense (LOGMARS), automotive, ID badges, inventory | Shipping and logistics labels, GS1-128 | Retail point of sale in the US |
UPC-A numbers must come from GS1 to be valid at retail checkout, so this tool does not generate them; Code 39 and Code 128 need no registration.
How Code 128 Barcodes Work
Code 128 is a high-density linear barcode symbology that can encode all 128 ASCII characters. It is one of the most widely used barcode formats in logistics, shipping, inventory management, and retail. Each character is represented by a pattern of bars and spaces with three different widths. The barcode includes a start character, the encoded data, a checksum character for error detection, and a stop pattern.
This tool implements Code 128B encoding, which supports the full range of printable ASCII characters (space through tilde). The barcode is rendered directly onto an HTML5 Canvas element using JavaScript, calculating the exact bar widths and positions for each character in your input. The checksum is computed automatically to ensure the barcode is valid and scannable. Because everything runs in your browser, your data is never transmitted to any server.
Code 128 Structure
Start Code B: Initiates encoding for ASCII characters 32-127
Data Characters: Each character encoded as 3 bars and 3 spaces (11 modules)
Checksum: (Start value + Σ(position × character value)) mod 103
Stop Pattern: Fixed 13-module termination sequence
The resulting barcode is compact, machine-readable, and compatible with virtually all barcode scanners.
Common Uses for Barcodes
Barcodes are used extensively in retail for product identification (UPC/EAN), in logistics for package tracking, in libraries for book management, in healthcare for patient identification and medication tracking, and in manufacturing for inventory control. Code 128 is particularly popular for shipping labels, asset tags, and internal inventory systems because of its ability to encode both text and numbers in a compact format.
Barcode Design Tips
For reliable scanning, ensure adequate quiet zones (blank space) on both sides of the barcode. The recommended minimum quiet zone is 10 times the narrowest bar width. Use high contrast between the bars and background (black bars on white background works best). Avoid scaling barcodes too small, as narrow bars may become unreadable. A minimum height of 15 percent of the barcode width is recommended for handheld scanners.
Privacy and Security
All barcode generation happens entirely in your browser. Your text data is never uploaded to any server, making this tool completely safe for encoding sensitive inventory codes, internal tracking numbers, or confidential identifiers.
Last updated: October 2026
Frequently Asked Questions
Can barcode scanners read the barcodes generated by this tool?
Yes. This tool generates standard Code 128B barcodes with proper start codes, checksums, and stop patterns. The output is compatible with all barcode scanners and readers that support the Code 128 symbology.
Is my data sent to a server?
No. All barcode generation happens locally in your browser using JavaScript and the HTML5 Canvas API. Your text data never leaves your device, making this tool safe for sensitive or confidential codes.
What characters can I encode in a Code 128 barcode?
Code 128B supports all standard printable ASCII characters including letters (uppercase and lowercase), numbers, spaces, and common punctuation marks. This covers characters from space (ASCII 32) through tilde (ASCII 126).
Is Barcode Generator free to use?
Yes, Barcode Generator is completely free with no sign-up, no login, and no hidden fees. The tool runs entirely in your browser — your data never leaves your device.
Is my data safe when using this tool?
Yes. This tool runs 100% in your browser using JavaScript. No data is sent to any server, stored in any database, or shared with any third party. When you close the page, processing stops immediately.
What is the difference between Code 39 and Code 128?
Code 39 encodes 43 characters (0-9, uppercase A-Z, space and - . $ / + %) with an optional mod 43 check digit, and can be printed with a simple font plus asterisks. Code 128 encodes the full ASCII set, always includes a mod 103 check digit and is denser, so the same data gives a shorter barcode. Use Code 128 for shipping labels and Code 39 when a spec such as LOGMARS or an automotive label requires it.
Why does a Code 39 barcode start and end with an asterisk?
The asterisk (*) is the Code 39 start/stop character. Scanners use it to find where the symbol begins and ends, so it can never appear inside your data. If you use a Code 39 font in Word or Excel you must type the asterisks yourself, for example *ABC123*. This generator adds them automatically, and its Copy button gives you the asterisk-wrapped text.