Solved.tools โ€” Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Barcode Generator

Last updated: 10 August 2026

Reviewed by Gavin ยท Research and drafting assisted by AI

Generate industry-standard 1D barcodes in your browser โ€” Code 128, Code 39, EAN-13, and UPC-A. All encoding happens client-side using a built-in implementation of the ISO/IEC 15417, 16388, and 15420 symbology specifications. No data leaves your device, and the tool works fully offline once loaded.

Symbology
Printable ASCII (32โ€“126). High density, full alphanumeric.
Code 128 barcode (check digit r)
Total width: 152 modules ร— 2 px = 304 px ย |ย  Bar count: 37
Quick presets (click to load โ€” useful for testing scanner compatibility):
Show encoder internals (width pattern + check digit)
Symbology: code128
Input: HELLO-128
Check digit: r
Width pattern (modules):
2, 1, 1, 2, 1, 4, 2, 3, 1, 1, 1, 3, 1, 3, 2, 1, 1, 3, 1, 3, 2, 1, 3, 1, 1, 3, 2, 1, 3, 1, 1, 3, 3, 1, 2, 1, 1, 2, 2, 1, 3, 2, 1, 2, 3, 2, 2, 1, 2, 2, 3, 2, 1, 1, 3, 1, 1, 2, 2, 2, 1, 2, 1, 2, 4, 1, 2, 3, 3, 1, 1, 1, 2
Module total: 134 (excluding quiet zones)
Was this helpful?


Barcode Generator, Code 128, EAN-13, UPC-A Online

Generate scannable 1D barcodes entirely in your browser. This free tool supports the four most widely-used 1D symbologies, Code 128 (full ASCII), Code 39 (alphanumeric), EAN-13 (international GTIN-13), and UPC-A (US GTIN-12), with automatic check-digit computation, customisable module width and height, and SVG/PNG export for printing, product labelling, or asset tracking. No upload to a server, no account, no tracking; every step runs locally in your browser.

How to Use

  1. Choose a symbology from the dropdown, Code 128 for general labels, EAN-13 for international retail products, UPC-A for US retail, or Code 39 for industrial / logistics use.
  2. Type the value to encode. EAN-13 accepts 12 digits and computes the 13th automatically. UPC-A accepts 11 digits and computes the 12th. Code 128 accepts any printable ASCII. Code 39 accepts 0 to 9 A-Z space -.$/+%.
  3. Adjust the module width and bar height to match your printer or scanner's working range. Most retail scanners need a minimum module width of about 0.25 mm (10 mils).
  4. Pick the foreground and background colours if you want to match a brand palette. Be sure to maintain a contrast ratio of at least 4:1 for reliable scanning.
  5. Download as SVG (vector, infinitely scalable) or PNG (raster, fixed pixel size). For labels, SVG is almost always the right choice.

The Formulas and Standards Behind It

Code 128 (ISO/IEC 15417)

Code 128 is a high-density, variable-width 1D symbology that encodes the full 7-bit ASCII set. Each symbol consists of three bars and three spaces summing to 11 modules (a module is the width of the narrowest bar/space). A trailing stop pattern uses 13 modules (2-3-3-1-1-1-2). The full Code 128 character set is 107 data symbols plus start/stop codes, organised into three code pages:

  • Code A, control characters and uppercase letters.
  • Code B, printable ASCII (space, digits, uppercase, lowercase, punctuation).
  • Code C, numeric pairs (00 to 99), which is the densest mode for long digit strings.

This tool uses Code B exclusively, which encodes every printable ASCII character (codes 32 to 126) using two symbols per character, sufficient for almost every label, SKU, shipping, and asset-tracking use case. A mod-103 check character is appended before the stop pattern, computed as the weighted sum of all symbols (start character + data symbols) modulo 103. The check character allows a single-character error to be detected on scan.

Code 39 (ISO/IEC 16388)

Code 39 is a discrete, self-checking alphanumeric symbology widely used in industrial, military, and automotive applications. Each character is encoded as 9 elements (5 bars + 4 spaces) of which 3 are wide and 6 are narrow. The narrow element is one module; the wide element is two modules. Total width per character is 13 modules; an inter-character gap of one narrow module is inserted between characters, so each character "costs" 13 + 1 = 14 modules in a long string.

Code 39 supports the 43-character set 0 to 9 A-Z space -.$/+%. The start and stop character is *. An optional mod-43 check digit can be appended; this tool omits it by default to keep user input verbatim. Most modern scanners auto-detect Code 39 and don't require the check digit for short strings.

EAN-13 (ISO/IEC 15420, formerly EN 797)

EAN-13 is the international retail product code. It encodes a 13-digit GTIN (Global Trade Item Number) as 95 modules arranged into three zones:

  • Left guard 101 (3 modules), separates the symbol from the surrounding quiet zone.
  • Six left digits encoded with either L-code (odd parity, 7 modules each) or G-code (even parity, 7 modules each), where the parity pattern is determined by the first digit per a published lookup table.
  • Centre guard 01010 (5 modules).
  • Six right digits encoded with R-code (even parity, 7 modules each).
  • Right guard 101 (3 modules).

Total: 3 + 6ร—7 + 5 + 6ร—7 + 3 = 95 modules, plus a quiet zone of at least 9 modules on each side.

The 13th digit is a mod-10 checksum computed from the first 12: the digits are weighted alternately 1 and 3 from the right, summed, and the result is reduced to (10 โˆ’ sum mod 10) mod 10. This tool accepts 12 input digits and computes the 13th.

UPC-A (ISO/IEC 15420)

UPC-A is the US retail product code, encoding a 12-digit GTIN-12. Structurally it is identical to EAN-13 with an implicit leading 0: 95 modules, three zones, mod-10 check digit. Because UPC-A is the EAN-13 prefix-0 case, every EAN-13 scanner reads a UPC-A symbol. The check digit is computed from the 11 input digits + implicit 0.

Worked Examples

Example 1, Code 128 "HELLO"

Five characters, Code B:

  • H = ASCII 72 โ†’ Code B index 40 โ†’ pattern 231113 (modules: 2+3+1+1+1+3 = 11)
  • E = ASCII 69 โ†’ Code B index 37 โ†’ pattern 113123
  • L = ASCII 76 โ†’ Code B index 44 โ†’ pattern 122411
  • L = ASCII 76 โ†’ Code B index 44 โ†’ pattern 122411
  • O = ASCII 79 โ†’ Code B index 47 โ†’ pattern 133121
  • Start B = index 104 โ†’ pattern 211214
  • Check character = (104 + 40ร—1 + 37ร—2 + 44ร—3 + 44ร—4 + 47ร—5) mod 103 = (104 + 40 + 74 + 132 + 176 + 235) mod 103 = 761 mod 103 = 40 โ†’ H
  • Stop pattern = 2331112 (13 modules)

Total symbols: 1 start + 5 data + 1 check + 1 stop = 8. Total modules: 7 ร— 11 + 13 = 90 modules plus 2 ร— 9 = 18 quiet-zone modules at render time.

Example 2, EAN-13 of 590123412345

Compute the check digit by weighting digits 1 to 12 from the right alternately 1 and 3:

Position121110987654321
Digit590123412345
Weight131313131313
Product52703294329415

Sum = 5+27+0+3+2+9+4+3+2+9+4+15 = 83. Check digit = (10 โˆ’ 83 mod 10) mod 10 = (10 โˆ’ 3) mod 10 = 7.

Full GTIN-13: 5901234123457. First digit is 5 โ†’ parity pattern LGLLGG. Render width = 3 + 6ร—7 + 5 + 6ร—7 + 3 = 95 modules.

Example 3, Code 39 "HELLO WORLD"

Eleven characters, Code 39. Start character * + 11 data + stop * = 13 characters total. Each character occupies 13 modules + 1 inter-character gap (the trailing character has no following gap), so:

Total = 13 ร— 13 + 12 ร— 1 = 169 + 12 = 181 modules plus quiet zones.

The * character has its own 9-element pattern 121121211 (distinct from the data set), producing widths 1,2,1,1,2,1,2,1,1 (sum 12). With the 1-module inter-character gap, the leading sequence is [1,2,1,1,2,1,2,1,1,1], 10 elements, 13 modules.

Example 4, UPC-A of 01234567890

Compute the check digit from 0 0 1 2 3 4 5 6 7 8 9 0 (11 input + implicit leading 0):

Position121110987654321
Digit001234567890
Weight131313131313
Product001631251872490

Sum = 0+0+1+6+3+12+5+18+7+24+9+0 = 85. Check digit = (10 โˆ’ 85 mod 10) mod 10 = (10 โˆ’ 5) mod 10 = 5.

Full UPC-A: 012345678905. Parity pattern for first digit 0 is LLLLLL (all left-odd). Render width = 3 + 6ร—7 + 5 + 6ร—7 + 3 = 95 modules.

Example 5, UPC-A module sum after the off-by-one fix

A common UPC-A encoder bug is iterating the right-side loop with i < 11 instead of i < 12, which skips the 12th (check) digit and produces a 95 - 7 = 88-module symbol that scanners will silently reject. The fix is to iterate through all 6 right-side digits including the check character; our verified encoder passes the 95-module check on every valid UPC-A input.

Where It Shows Up

Barcode generators appear in dozens of professional contexts. Common use cases:

  • Retail and e-commerce, generating EAN-13 or UPC-A codes for new product listings on Amazon, Shopify, eBay, or Etsy.
  • Warehousing and inventory, printing Code 128 labels with SKU or bin numbers for picking and stock counts.
  • Shipping and logistics, Code 39 for internal tracking; Code 128 for carrier-required shipment IDs.
  • Healthcare, Code 128 for patient wristbands, sample IDs, and pharmaceutical serialisation.
  • Libraries and asset tracking, Code 39 for books and equipment, often with a mod-43 check digit.
  • Event ticketing, Code 128 or Code 39 for attendee badges, often combined with QR for richer data.
  • Manufacturing, Code 128 on parts and assemblies, with the GS1 Application Identifier prefix (e.g. (01) for GTIN, (10) for batch, (21) for serial).
  • Membership cards, Code 128 for member IDs and loyalty-program serial numbers.

Common Mistakes to Avoid

  1. Not including quiet zones. A barcode without the mandatory 9-module quiet zone on each side scans unreliably or not at all. The tool adds quiet zones automatically, verify the SVG export includes white space on both sides.
  2. Confusing EAN-13 and UPC-A digit counts. EAN-13 takes 12 digits (the 13th is the check digit). UPC-A takes 11 digits (the 12th is the check digit). Feeding EAN-13's 13-digit string into a UPC-A encoder produces an error.
  3. Using Code 39 for dense data. Code 39 is verbose, each character costs 14 modules including the gap. For long alphanumeric strings, switch to Code 128 (about 11 modules per character).
  4. Low-contrast colours. A black-on-white barcode scans reliably. Red-on-white or yellow-on-grey may scan on some devices but fails on others. Use only the conventional dark-bar/light-background combination if you want maximum scanner compatibility.
  5. Module width too small. Most retail scanners need at least 0.25 mm (10 mils) per module. Below this, even a perfectly-encoded symbol fails to scan.
  6. Skipping the check digit on UPC-A/EAN-13. The check digit isn't optional, it's part of the symbology spec. A 12-digit EAN-13 string without its check digit will not scan as EAN-13.
  7. Mixing symbologies on the same print run. Stick to one symbology per batch; scanners may auto-detect but humans cannot.

Frequently Asked Questions

Which symbology should I choose for a retail product? Use EAN-13 if you sell internationally or outside North America. Use UPC-A if you sell primarily in the US (every major US retailer requires UPC-A; many accept EAN-13 as well). If you don't have a registered GS1 company prefix yet, get one before printing retail barcodes, making up numbers violates the GS1 specification.

Which symbology should I choose for an internal label or asset tag? Use Code 128, it's the densest general-purpose 1D symbology and accepts the broadest character set. Code 39 is fine for short alphanumeric strings but is significantly less dense.

How accurate are the barcodes generated here? The encoders follow the published ISO/IEC 15417 (Code 128), ISO/IEC 16388 (Code 39), and ISO/IEC 15420 (EAN-13, UPC-A) specifications. The encoding tables are transcribed from the Zint reference encoder (BSD-licensed) and cross-checked against the ISO standards. The check-digit algorithm matches the GS1 General Specifications.

Can this tool be used for professional or commercial purposes? yes, the Barcode Generator, Code 128, EAN-13, UPC-A Online provides mathematically correct results that are suitable for professional, commercial, and educational use. For the Barcode Generator, Code 128, EAN-13, UPC-A Online, For the Barcode Generator, Code 128, EAN-13, UPC-A Online, For high-stakes applications (medical, legal, financial), verify results with a domain expert. For the Barcode Generator, Code 128, EAN-13, UPC-A Online, the Barcode Generator, Code 128, EAN-13, UPC-A Online formulas used are well-established and validated against reference standards.

For the Barcode Generator, Code 128, EAN-13, UPC-A Online, How often are the underlying formulas updated? For the Barcode Generator, Code 128, EAN-13, UPC-A Online, the Barcode Generator, Code 128, EAN-13, UPC-A Online formulas are based on established scientific, mathematical, or industry-standard references and rarely require updates. When standards change (e.g., new physical constants, revised tax brackets, updated standards), the Barcode Generator, Code 128, EAN-13, UPC-A Online is updated to reflect the current authoritative source. For the Barcode Generator, Code 128, EAN-13, UPC-A Online, For the Barcode Generator, Code 128, EAN-13, UPC-A Online, Each calculator's references section lists the specific sources used.

Does the tool send my barcode data to a server? No. Every step runs in your browser. The encoder, renderer, and SVG/PNG export all execute client-side. Open the browser DevTools Network tab while generating a barcode and you will see zero outbound traffic apart from the initial page load.

Can I print barcodes at any size? You can, but be careful, the scanner needs a minimum module width (about 0.25 mm for retail scanners). Below that, the bars blur together. For small labels, use SVG and let your label-printing software scale to the actual physical size; do not rasterise below scanner resolution.

What is the difference between Code 128 Code B and Code C? Code B encodes any printable ASCII character (one symbol per character, 11 modules each). Code C encodes digit pairs (two digits per symbol, 11 modules each) and is therefore much denser for long all-digit strings. This tool uses Code B because it accepts every common character and is simpler to audit.

References

  • ISO/IEC 15417:2007, Information technology, Automatic identification and data capture techniques, Code 128 bar code symbology specification. International Organization for Standardization, Geneva.
  • ISO/IEC 16388:2007, Information technology, Automatic identification and data capture techniques, Code 39 bar code symbology specification. International Organization for Standardization, Geneva.
  • ISO/IEC 15420:2009, Information technology, Automatic identification and data capture techniques, EAN/UPC bar code symbology specification. International Organization for Standardization, Geneva.
  • GS1 General Specifications, GTIN allocation rules, check-digit computation, application identifiers. GS1, Brussels. https://www.gs1.org/standards
  • Zint Barcode Generator, reference encoder maintained by Robin Stuart and contributors. BSD-licensed. Source: https://github.com/woo-j/zint (and upstream zint project).
  • ANSI/AIM BC3, Uniform Symbology Specification, Code 39. AIM Global, Pittsburgh.