Generating Code128, EAN, UPC, and QR barcodes offline

Published: 2026-09-05

When to use Code128 vs EAN-13/8 vs UPC-A vs QR, how GS1 check digits work, quiet zone and contrast tips, and how to generate PNG or SVG barcodes in the browser without uploading payloads.

A barcode turns a short string into a machine-readable pattern of bars or modules. Warehouse scanners, retail POS, and phones all decode that pattern back to text. The hard part for product and ops teams is picking the right symbology, getting check digits right for retail GTINs, and exporting art that still scans after print—without pasting SKUs or URLs into a random online generator.

This guide compares Code128, EAN-13, EAN-8, UPC-A, and QR, explains GS1 check digits in plain language, and shows how to render symbols locally in the browser.

Linear vs 2D (what you are encoding)

Kind Shape Typical data Common use
Linear (1D) Vertical bars + quiet margins Short numeric or ASCII strings Retail GTINs, shipping labels, internal SKUs
2D (QR) Square grid of modules Longer text, URLs, Wi-Fi, vCards Marketing links, tickets, contacts

Linear codes are built for laser and CCD scanners that sweep a line. QR codes need a camera (or 2D imager) and tolerate more damage via error correction—see QR codes: error correction and use cases for L/M/Q/H levels and quiet-zone rules.

Pick linear when the consumer is a retail scanner or a handheld that already expects EAN/UPC/Code128. Pick QR when phones should open a URL or join Wi-Fi without a dedicated barcode gun.

Code128: flexible alphanumeric labels

Code128 encodes the full printable ASCII set (letters, digits, punctuation). It is the usual choice for internal SKUs, cartons, and warehouse labels where you control the alphabet and do not need a GS1 retail GTIN on the shelf edge.

Practical notes:

  • Keep payloads short. Longer strings make wider symbols; scanners struggle when bars shrink on a tiny label.
  • Prefer a stable character set. Mixing weird Unicode may fail or be stripped depending on the encoder; stick to printable ASCII for warehouse IDs.
  • Human-readable text under the bars helps operators when the scan fails—toggle it on for print proofs, off for ultra-compact stickers if space is tight.

Code128 does not replace EAN/UPC at checkout in most grocery chains. If the product must ring up in a global retail catalog, you need a proper GTIN symbology (below).

EAN-13, EAN-8, and UPC-A: retail numbers with a check digit

Retail barcodes encode a Global Trade Item Number (GTIN) as digits only. The last digit is a check digit from the GS1 algorithm so mistyped or damaged digits fail verification instead of ringing up the wrong item.

Symbology Digits (with check) Body length (no check) Region / role
EAN-13 13 12 Default retail GTIN worldwide
EAN-8 8 7 Compact packaging when space is tight
UPC-A 12 11 North American retail (closely related to EAN-13)

How the check digit works (intuition): treat the body digits from the right, multiply alternating positions by 3 and 1, sum them, then choose a final digit so the total is divisible by 10. You do not need to memorize the arithmetic—generators append or validate it—but you do need the correct body length:

  • Paste 12 digits → tool appends the EAN-13 check digit.
  • Paste 11 digits → tool appends the UPC-A check digit.
  • Paste 7 digits → tool appends the EAN-8 check digit.
  • Paste a full code including check digit → tool verifies it and rejects a wrong checksum.

Spaces and dashes in pasted numbers are usually ignored; letters are not allowed. A wrong check digit is a common reason a “valid-looking” GTIN will not render or will not scan at POS.

UPC-A vs EAN-13: UPC-A is twelve digits; many systems treat it as an EAN-13 with a leading zero. Do not invent check digits by hand for production packaging—use a verified calculator or a local encoder that implements GS1.

QR codes in the same toolkit

A QR symbol stores an arbitrary string (URL, ticket token, Wi-Fi WIFI:… payload, vCard). Capacity and damage tolerance depend on error correction and physical size. For deep guidance on ECC levels, quiet zones, and payload conventions, use the dedicated QR guide; for a quick offline PNG/SVG of a URL or SKU string beside your linear codes, the same Barcode Generator can switch symbology to QR.

Remember: anything in a QR is recoverable by anyone who photographs it. Guest Wi-Fi passwords and personal vCards belong in a local generator, not an upload form (Why “local only” matters for developer tools).

Quiet zone, contrast, size, and export format

Scanners need a blank quiet zone (margin) around the symbol—same idea as QR’s four-module border. Cropping bars flush to a package edge is a frequent cause of “won’t scan.”

Other print basics:

  • Contrast. Dark bars on a light background beat low-contrast brand colors under warehouse lighting.
  • Bar width / height. Too thin and laser scanners miss bars; too short and handhelds fail at an angle. Preview at real print size when you can.
  • PNG vs SVG. PNG is fine for fixed-resolution stickers and email proofs. SVG scales cleanly for print layouts and vector design tools. MIME labels for those exports are covered in MIME types and file extensions.

Generate offline (no upload)

Online barcode sites often POST your SKU, GTIN, or URL to a server. For pre-release product codes and internal inventory IDs, that is unnecessary risk. A browser tool can run JsBarcode (linear) and a QR library in the tab, append GS1 check digits locally, and download PNG or SVG without leaving the device.

Open Barcode Generator:

  1. Choose Code128, EAN-13, EAN-8, UPC-A, or QR.
  2. Enter the payload. For EAN/UPC, paste the body without a check digit to auto-append, or paste the full code to validate.
  3. Tune colors, bar width/height, quiet zone, and optional human-readable text.
  4. Download PNG or SVG from the live preview.

Payloads never leave this device—same privacy model as other LocalTools media utilities.

Related reading

All learn articles