Barcode Generator — Free Online Tool

Generate Code 128 barcodes in the browser. Produces SVG output for product labels, inventory tags, and shipping barcodes. Scalable, printable, no upload required.

Use this free online Barcode Generator directly in your browser. No signup required, no data leaves your device. Part of Utilier — a collection of 133+ developer utilities.

What is Code 128 Barcode Generator?

Code 128 is a high-density linear barcode symbology that encodes alphanumeric data (letters, numbers, symbols) into a series of vertical bars. This tool generates Code 128 barcodes from any text or number input and outputs scalable SVG graphics that can be printed at any size without quality loss.

Code 128 is a one-dimensional barcode standard designed for compact alphanumeric data such as stock codes, order numbers, and shipment labels. A scanner reads the bar pattern, start and stop markers, and checksum to reconstruct the original value. Reliable printed barcodes need adequate contrast, quiet space at both edges, and module dimensions suited to the printer and scanner.

  • High-density encoding: Code 128 can encode the full ASCII character set (0–127) including uppercase, lowercase, digits, and punctuation. It is more compact than Code 39 or Interleaved 2 of 5 for the same data.
  • SVG output: The barcode is generated as an SVG (Scalable Vector Graphics) file, so it scales to any size without pixelation. Perfect for printing on labels, shipping boxes, or product packaging.
  • Automatic subset selection: Code 128 has three subsets (A, B, C) for different character ranges. The tool automatically selects the most compact encoding: subset C for numeric-only data (encodes two digits per symbol), subset B for mixed alphanumeric.
  • Quiet zones included: The output includes the required white space (quiet zones) on both sides of the barcode, ensuring scanners can read it reliably even when printed near edges or other graphics.
  • Checksum calculation: Code 128 includes a checksum digit (modulo 103) that the tool calculates automatically. Scanners verify the checksum to detect printing defects or scan errors.

Why use barcode generator?

Barcodes are essential for inventory management, shipping, asset tracking, and point-of-sale systems. Generating them manually or with commercial software is slow and expensive. This tool produces professional-quality barcodes instantly in the browser.

  • No software installation: No need for Photoshop plugins, barcode fonts, or commercial barcode generators. Generate barcodes directly in the browser and download as SVG.
  • Scalable for any print size: SVG is vector-based, so the barcode scales to tiny labels (2cm wide) or large shipping boxes (15cm wide) without losing clarity. No pixelation, ever.
  • Instant preview: See the barcode immediately as you type. Verify the data is correct before printing hundreds of labels.
  • Batch-ready: Generate one barcode, or automate batch generation by embedding the tool's logic in a script or system.
  • Compatible with all scanners: Code 128 is ISO/IEC 15417 standard and supported by all barcode scanners, warehouse systems, and point-of-sale terminals.
  • Runs locally: Your data stays in the browser. Safe for generating product SKUs, internal inventory codes, or any sensitive identifiers.

When to use barcode generator

Use whenever you need a machine-readable barcode for products, assets, or shipments.

  • Creating product labels for inventory, retail, or e-commerce shipping.
  • Generating shipping barcodes for packages (tracking numbers, order IDs).
  • Printing asset tags for IT equipment, furniture, or tools in warehouses.
  • Producing membership cards, ID badges, or ticket barcodes that scanners can read.
  • Adding barcodes to invoices, packing slips, or receipts for automated processing.
  • Testing barcode scanner hardware or software with known test data.
  • Generating barcodes for internal tracking systems (work orders, part numbers, bin locations).

How to use barcode generator

One input field, instant barcode output.

  1. Enter the text or number to encode: Type any alphanumeric text: product SKU, tracking number, order ID, serial number, etc. Code 128 supports all ASCII characters including uppercase, lowercase, digits, spaces, and symbols.
  2. See the barcode preview: The barcode appears instantly below the input. Each character is encoded as a unique bar pattern, with start/stop codes and a checksum automatically added.
  3. Adjust height or width if needed: Use the controls to change barcode height (for scanner reliability) or module width (bar thickness). Taller barcodes are easier to scan at oblique angles; wider modules print more reliably on low-DPI printers.
  4. Download as SVG: Press Download SVG to save the barcode as a scalable vector file. Open it in design software (Illustrator, Inkscape, Figma), embed it in documents, or send it to a label printer.
  5. Print and test: Print the barcode and test with a scanner. If scanning fails, increase the module width (thicker bars) or height, ensure good print quality, and verify quiet zones are not cropped.

Key features

  • Code 128 encoding: High-density alphanumeric barcode supporting full ASCII (0–127). More compact than Code 39 for mixed data.
  • SVG output: Scalable vector graphics that print clearly at any size, from tiny labels to large shipping boxes.
  • Automatic subset optimization: Selects subset C for numeric-only data (encodes two digits per symbol), subset B for alphanumeric, minimizing barcode length.
  • Checksum calculation: Automatically calculates and includes the modulo-103 checksum digit for error detection.
  • Quiet zones included: Output includes the required white space margins on both sides for reliable scanning.
  • Adjustable dimensions: Customize barcode height and module width (bar thickness) for different label sizes and printer capabilities.
  • Instant preview: See the barcode as you type, with the encoded value displayed below.

Common use cases

  • Product labeling: Generate barcodes for SKUs, UPCs, or internal product codes for retail, e-commerce, or warehouse inventory.
  • Shipping and logistics: Create tracking number barcodes for packages, pallets, or containers.
  • Asset management: Print asset tags for IT equipment, tools, furniture, or vehicles with unique IDs or serial numbers.
  • Document tracking: Add barcodes to invoices, packing slips, work orders, or receipts for automated sorting and lookup.
  • Access control: Generate membership cards, event tickets, or ID badges with scannable barcodes.
  • Testing and prototyping: Create test barcodes for scanner hardware, software integration, or system demos.

Examples

Actual barcodes generated by this tool.

Product SKU

ABC-12345-XYZ
(Code 128 barcode SVG with bars encoding 'ABC-12345-XYZ')

Encodes letters, digits, and hyphens. The barcode includes start code, data characters, checksum, and stop code. Quiet zones are added automatically.

Tracking number (numeric)

9876543210
(Code 128C barcode, compact numeric encoding)

All-numeric data uses subset C, which encodes two digits per symbol. The barcode is half the length of subset B encoding.

Order ID (mixed alphanumeric)

ORD-2024-08-15-A
(Code 128B barcode)

Mixed uppercase, digits, and hyphens use subset B. The barcode is readable by all scanners and includes the checksum for error detection.

Serial number with lowercase

sn-2024abc
(Code 128B barcode with lowercase support)

Code 128 subset B supports lowercase letters, unlike Code 39. The barcode is compact and universally scannable.

Internal part number

PT#4567
(Code 128B barcode encoding 'PT#4567')

Encodes symbols like # (hash) correctly. Code 128 supports all printable ASCII characters.

Technical reference

The Code 128 standard and technical details:

Standard
ISO/IEC 15417 — Code 128 bar code symbology specification
Character set
Full ASCII (0–127): uppercase, lowercase, digits, punctuation, control characters
Subsets
A (control chars, uppercase, digits), B (uppercase, lowercase, digits, symbols), C (numeric pairs, 00–99)
Density
High — encodes up to 6 characters per inch at 10 mil (0.25mm) module width
Checksum
Modulo 103 checksum digit, automatically calculated and appended. Scanners verify the checksum to detect errors
Quiet zones
Minimum 10 times the module width on each side. The tool includes these automatically
Module width
Typical: 0.25mm (10 mil) to 0.5mm (20 mil). Smaller = more compact, larger = easier to print and scan
Bar height
Minimum 15% of barcode width or 5mm, whichever is greater. Taller barcodes are easier to scan at angles
Scanner compatibility
Universal — all barcode scanners (laser, CCD, 2D imagers) and inventory systems support Code 128
Comparison to Code 39
Code 128 is more compact (smaller barcode for same data) and supports lowercase. Code 39 is older, simpler, uppercase+digits only

Common mistakes to avoid

Printing barcodes without quiet zones (white margins)

Why it happens: The quiet zone is the blank space required on both sides of a barcode. Scanners use it to detect the start and end of the barcode. If you crop the SVG too tightly or print the barcode right at the edge of a label, the scanner may not recognize it. The result: scanning fails intermittently or only works at perfect angles.

How to avoid it: Always preserve the quiet zones in the SVG. The tool includes them automatically (10x module width on each side). When printing, ensure the label has at least 2–3mm of white space around the barcode. Test with a scanner before mass-printing.

Using too small a module width (bar thickness) for low-DPI printers

Why it happens: Module width is the width of the narrowest bar in the barcode. If you set it too small (e.g., 0.2mm on a 203 DPI label printer), the printer cannot resolve individual bars — they bleed together or disappear. The barcode prints as a blur or solid black rectangle, and scanners cannot read it.

How to avoid it: Match module width to your printer's resolution. For 203 DPI printers, use 0.3mm (12 mil) minimum. For 300 DPI, 0.25mm (10 mil) is safe. For inkjet or laser printers, test a sample before batch printing. If scans fail, increase the module width.

Embedding very long text (100+ characters) in a single barcode

Why it happens: Code 128 can technically encode long strings, but the barcode becomes extremely wide. A 100-character barcode at 0.3mm module width is 30+ cm long — too wide for most labels and hard to scan in one pass. Scanners may timeout or misread partial data.

How to avoid it: Keep barcode data under 30–40 characters for standard label sizes. If you need to encode more data, use a 2D barcode (QR code, Data Matrix) which stores far more in a small square. For Code 128, encode only the essential identifier (SKU, tracking number) and store additional data in a database.

Not testing barcodes with the actual scanner before mass-printing

Why it happens: Barcodes can look perfect on screen but fail to scan due to print quality (ink bleed, low contrast), label material (reflective, textured), or scanner settings (wrong symbology enabled, low sensitivity). Printing 10,000 labels only to discover they do not scan is costly.

How to avoid it: Print a test sheet of 5–10 barcodes and scan them with the actual scanner you will use in production. Test at different angles, distances, and lighting. If scans fail, adjust module width, height, or print quality. Only mass-print after successful testing.

Using Code 128 when a QR code would be better

Why it happens: Code 128 is a 1D (linear) barcode — it encodes data in one direction (horizontal bars). It is great for short alphanumeric IDs (product codes, tracking numbers) but inefficient for URLs, long text, or data that needs error correction. QR codes are 2D (matrix), store much more data in less space, and have built-in error correction (can still scan if partially damaged).

How to avoid it: Use Code 128 for product SKUs, serial numbers, tracking IDs, and other short identifiers that will be scanned with handheld barcode scanners. Use QR codes for URLs, Wi-Fi credentials, contact info, event tickets, or any data longer than ~40 characters. QR codes are also better for smartphone scanning.

Frequently asked questions

What is the difference between Code 128 and QR codes?

Code 128 is a 1D (linear) barcode: horizontal bars encoding alphanumeric data, compact for short strings (product codes, tracking numbers), scanned with laser or CCD barcode scanners. QR codes are 2D (matrix) barcodes: black and white squares encoding much more data (URLs, text, contact info), scanned with smartphone cameras or 2D imagers, and have error correction (readable even if partially damaged). Use Code 128 for inventory and shipping; use QR for URLs and marketing.

Can I use Code 128 barcodes for UPC product codes?

No. UPC (Universal Product Code) is a specific 12-digit barcode standard (UPC-A) used in retail point-of-sale systems. It has a fixed format and requires a GS1 company prefix. Code 128 can encode the same numbers, but it is not a UPC and will not scan correctly at retail checkout. If you need UPCs, you must obtain them from GS1. Use Code 128 for internal inventory, shipping, or asset tracking where UPC compatibility is not required.

How wide should the quiet zone (white margin) be?

The quiet zone is the blank space on both sides of the barcode. Code 128 requires a minimum of 10 times the module width (bar thickness) on each side. For a 0.3mm module, that is 3mm of white space. The tool includes this automatically in the SVG. When printing, ensure the label has at least this much margin — do not crop the SVG or print right to the edge.

What is the maximum length for Code 128 barcodes?

Theoretically unlimited, but practical limits apply. Each character adds ~11 modules (bars/spaces), so a 40-character barcode at 0.3mm module width is ~13cm long. Most label printers support up to 10–15cm wide labels. Beyond 30–40 characters, the barcode becomes too wide for standard labels and hard to scan. For longer data, use a 2D barcode like QR or Data Matrix.

Can I print Code 128 barcodes on a regular inkjet or laser printer?

Yes, but print quality matters. Inkjet and laser printers work well for Code 128 if the module width is 0.3mm or larger and the printer has 300+ DPI resolution. Use high-quality, non-glossy paper to avoid ink bleed or reflection. Print a test, scan it, and adjust module width or height if needed. For mass production, thermal label printers (Zebra, Dymo) are more reliable and cost-effective.

Why does the barcode not scan even though it looks correct?

Common reasons: (1) Quiet zones cropped — ensure white margins on both sides. (2) Module width too small for printer resolution — increase bar thickness. (3) Low print contrast — use black bars on white background, avoid gray or colored labels. (4) Scanner not configured for Code 128 — check scanner settings. (5) Barcode damaged or smudged — reprint. Print a test and scan before mass production.

Can Code 128 encode lowercase letters?

Yes. Code 128 subset B supports uppercase letters (A–Z), lowercase letters (a–z), digits (0–9), and common symbols. This makes it more versatile than Code 39, which only supports uppercase. The tool automatically selects the best subset for your data.

References

Privacy and availability

  • Runs entirely in your browser — zero server processing
  • No signup or account required
  • Works offline once loaded
  • Fast, lightweight, no external dependencies
  • Available as a browser extension for Chrome and Firefox