Barcode Generator
QRGenerate 1D barcodes (CODE128, EAN, UPC, CODE39 and more) as PNG or SVG.
On this page
What is a barcode generator?#
A 1D barcode is the stack of vertical black bars you still see on every product package, shipping label and event ticket. Unlike a QR code (which is 2D and carries hundreds of bytes), a 1D barcode carries a short identifier — usually 4 to 14 characters — that a laser scanner or phone camera reads in a single horizontal sweep. This page renders eleven of the most common symbologies in your browser and exports the result as PNG or SVG.
The reason there are so many formats is that each was designed for a different industry constraint. EAN-13 and UPC are the retail standard: a fixed length, digits only, with a mathematically computed check digit so the scanner can reject misreads. CODE128 carries any ASCII text and is the workhorse for shipping (tracking numbers, for instance). CODE39 is the legacy alphanumeric format still found on badges and asset tags. ITF-14 encodes 14-digit shipping-container codes. Pharmacode packs a single integer (3 to 131070) into a tiny symbol for pharmaceutical packaging. MSI, codabar, EAN-5 and EAN-2 round out the niche cases.
This page wraps JsBarcode, which draws onto a <canvas> for raster output or an <svg> element for vector output. Before it hands off to the library it runs a quick local check, so you get a friendly message (“digits only” or “wrong length”) instead of a silent failure.
How to use it#
- Type or paste your value into the input box. The placeholder
123456789012hints at an EAN-13 length. - Pick the Format. Each symbology has its own charset and length rules — the dropdown lists all eleven (CODE128, CODE39, EAN13, EAN8, UPC, ITF14, MSI, codabar, pharmacode, EAN5, EAN2).
- Adjust Bar width (1–4 px per module) and Height (60, 100, 150 or 200 px). Narrower bars produce a denser, smaller code; taller bars scan more reliably from an angle.
- Hit Sample to preload a valid value for the selected format, or Clear to start over. The preview updates on the right.
- Download as PNG (for images and PDFs) or SVG (for print, where the code must stay crisp at any size).
Key features#
- Eleven symbologies in one tool. Retail (EAN-13/UPC), logistics (CODE128/ITF-14), assets (CODE39/MSI), pharma (pharmacode) and add-ons (EAN-5/EAN-2) — no format-hopping between sites.
- Check digit handled for you. For EAN-13, EAN-8, UPC and ITF-14, give 12/7/11/13 digits and the check digit is computed automatically; give the full length and it is validated.
- Pre-render validation. The tool catches empty input, non-digit characters in numeric formats, wrong lengths, and illegal CODE39/codabar characters before calling the renderer.
- Vector SVG export. Barcodes meant for print should never be rasterised — an SVG stays sharp at any label size.
- Runs locally. JsBarcode is bundled with the page; there is no backend and your value never leaves the browser.
Worked example#
Suppose you have a product with the 12-digit base 590123412345 and need an EAN-13. Select EAN13, paste 590123412345. The renderer computes the check digit (7) and draws the full 13-digit barcode. The human-readable line below the bars reads 5901234123457.
Check-digit math (so you can verify by hand): sum the digits in odd positions ×1 plus even positions ×3, then take (10 − total mod 10) mod 10. For 590123412345 that is (5+0+2+4+2+4)×1 + (9+1+3+1+3+5)×3 = 17 + 66 = 83, and 10 − 3 = 7.
For a shipping label, switch to CODE128 and paste an arbitrary tracking string like 1Z999AA10123456784 — CODE128 accepts the full ASCII range, so letters, digits and hyphens all encode directly.
FAQ#
EAN-13 keeps rejecting my 13-digit number — why?#
If you already typed the check digit, double-check it: re-type only the first 12 digits and let the tool append the 13th. A single transposed digit invalidates the checksum, and the renderer refuses to draw a code that would not scan.
My CODE39 barcode will not scan. What is wrong?#
CODE39 supports only uppercase letters A–Z, digits 0–9 and the symbols - . $ / + % (plus space). Lowercase letters are not part of the spec — convert them to uppercase first. The tool flags illegal characters with a “chars” error before rendering.
What is pharmacode, and why the weird range?#
Pharmacode is a binary-based symbology used on pharmaceutical packaging to encode a single integer that maps to an internal product ID. The valid range is 3 to 131070; anything outside that cannot be represented in the format.
Should I pick PNG or SVG?#
SVG for anything going to print (labels, packaging, documents) — it scales without pixelation. PNG is fine for screen display, email signatures and PDFs where a raster image is expected.